How can I iterate over an STL map inside an STL map?

I have an STL map definition as follows:

map<string, map<int, string> > info;

I iterate that map using the following code:

for( map<string, map<int, string> >::iterator ii=info.begin(); ii!=info.end(); ++ii){
    for(map<int, string>::iterator j=ii->second.begin(); j!=ii->second.end();++j){
        cout << (*ii).first << " : " << (*j).first << " : "<< (*j).second << endl;
    }
}

Is this the correct way to iterate or is there a better way to do so? The above code works for me, but I'm looking for a more elegant solution.

11
задан honk 20 March 2019 в 14:47
поделиться