我想在std :: map中使用std :: set
我对std ::容器没有太多的经验,所以我不确定我是否使用正确。我正在尝试处理一组值,并且每组中都是另一组值。
map<string, set<string> > data_map;
data_map["KEY1"].insert("VAL1");
data_map["KEY1"].insert("VAL2");
data_map["KEY2"].insert("VAL1");
data_map["KEY2"].insert("VAL3");
当我尝试访问地图中的设置时,我在这里收到错误(内部周期)
error: no match for call to ‘(std::set<std::basic_string<char> >) ()’|
error: no match for call to ‘(std::set<std::basic_string<char> >) ()’|
for( map<string, set<string> >::iterator mip = data_map.begin();mip != data_map.end(); ++mip) {
for ( set<string>::iterator sit = mip->second().begin(); sit != mip->second().end(); ++sit )
cout << *sit << endl;
}
您能告诉我如何迭代所有值吗?
mip->second().begin()
应该
mip->second.begin()
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句