J
jason.cipriani
In an std::map, iterators do not become invalid if other elements are
added erased. Just to make sure, does that mean that in the following
code:
map<string,B> m;
B *b = &(m["something"]);
The address in 'b' will remain valid, and always point to that same
object, as long as that data isn't erased from the map?
Similarily:
map<string,B> m;
map<string,B>::iterator i(m.find("something"));
B *b = (i == m.end()) ? NULL : &((*i).second);
Will b there also always remain valid as long as "something" remains
in the map?
Thanks,
Jason
added erased. Just to make sure, does that mean that in the following
code:
map<string,B> m;
B *b = &(m["something"]);
The address in 'b' will remain valid, and always point to that same
object, as long as that data isn't erased from the map?
Similarily:
map<string,B> m;
map<string,B>::iterator i(m.find("something"));
B *b = (i == m.end()) ? NULL : &((*i).second);
Will b there also always remain valid as long as "something" remains
in the map?
Thanks,
Jason