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

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -