How can I loop through a C++ map of maps?

How can I loop through a std::map in C++? My map is defined as:

std::map< std::string, std::map<std::string, std::string> >

For example, the above container holds data like this:

m["name1"]["value1"] = "data1";
m["name1"]["value2"] = "data2";
m["name2"]["value1"] = "data1";
m["name2"]["value2"] = "data2";
m["name3"]["value1"] = "data1";
m["name3"]["value2"] = "data2";

How can I loop through this map and access the various values?

9 Answers
9

Leave a Comment