I use something like this:
map<string, Data>::iterator it = mymap->begin();
map<string, Data>::iterator end = mymap->end();
while (it != end) {
// do stuff
++it;
}
I was just wondering if this would work even if the map is empty.
I couldn’t find any information about the return of map::begin() if the map ist empty.
If the map is empty, the
beginandenditerators are equal, i.e. returnsmymap->end().