c++ - Store pointer to map key -
std::map<key,value> mymap; (void)mymap[key(...)]; // create value if not there typename std::map<key,value>::iterator = mymap.find(key); it->second.pkey = &it->first; // store pointer actual key
is safe? in other words, map allowed copy key around during insert/erase operations, invalidate value::pkey
?
any c++98 vs c++11 differences on this?
std::map
iterators invalidated on erasure (erase
or clear
). inserting new elements map doesn't affect existing iterators. same in c++98 , c++11.
if iterator remains valid follows key points remains valid.
Comments
Post a Comment