【发布时间】:2010-11-26 20:25:18
【问题描述】:
我在尝试获取内部子容器的迭代器时遇到了麻烦。
基本上想象一下这个简化的代码:
typedef map<string, map<string, map> > double_map;
double_map dm;
.. //some code here
for(double_map::iterator it = dm.begin(); it != dm.end(); it++){
//some code here
it->first // string
it->second // <---- this is the 2nd map, how do i get its iterator so I can wrap it
//in a for loop like above?
}
我需要能够在不对每个内部容器使用 typedef 的情况下做到这一点,有没有办法为内部容器获取迭代器?我的结构有 4 个内部容器,我需要遍历它们。
【问题讨论】:
标签: stl iterator containers