I'd like to use std::set in std::map
I haven't much exp with std:: containers, so i am not sure if i am using it right. I am trying to process set of values and in each set is another set of values.
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");
I get error here when i try to access set in map (inner for-cycle)
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;
}
Could you please tell me how i can iterate all values?
second, notsecond()(it's a field ofstd::pair, not a method). Does that fix your issue?