for debugging I need to dump the contents of nested maps. I tried to describe this in the following code:
struct Foo
{
string name;
};
typedef std::map<string, Foo> MapFoo;
struct Bar {
string name;
MapFoo mapFoo;
};
typedef std::map<string, Bar> MapBar;
...
MapBar mapBar = init_mapBar();
const MapBar::const_iterator it = mapBar.find("name");
if ( mapBar.end() != it )
{
return it->second;
}
Before I return it->second, I want to dump the contents of that item to cout. I am getting lost with the iterators when trying doing this. Thank you very much for some help or hints.
Write a function:
You can then say:
and use it for dumping any other maps where K & V are types that have streaming operators available.