std::map<Key,Value> mymap;
(void)mymap[Key(...)]; // create value if not there
typename std::map<Key,Value>::iterator it = mymap.find(key);
it->second.pkey = &it->first; // store a pointer to the actual key
Is this safe? In other words, is map allowed to copy the key around during insert/erase operations, which would invalidate Value::pkey
?
Any C++98 vs C++11 differences on this?
Aucun commentaire:
Enregistrer un commentaire