3
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
这是安全吗?换句话说,映射是否允许在插入/擦除操作期间复制密钥,这会使Value::pkey
无效?存储指向地图键的指针
任何C++ 98与C++ 11的区别?
在'Value'中存储密钥并将指针_to_ key _as_用作自定义比较的密钥可能会有好处。取决于你的使用情况。 –