const_iterator如果您将地图定义为,如何使用find
pair
map<int, int>
用const_iterator定义为键.
如果它只是const_iterator,我知道如何使用pair喜欢
map<int, int>
const_iterator
等等..
如果您不使用C++ 11,最方便的是也typedef为地图类型执行:
typedef std::map<MyPair, int> map_type;
Run Code Online (Sandbox Code Playgroud)
然后
map_type::const_iterator it = MyMap.find(make_pair(0, 0));
Run Code Online (Sandbox Code Playgroud)
(我也改变了传递给的参数find,因为裸int与你的地图不兼容).
如果您使用的是C++ 11,那么您也可以做到
auto it = MyMap.find(make_pair(0, 0));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
22165 次 |
| 最近记录: |