std::map<std::string, std::string> myMap;
std::map<std::string, std::string>::iterator i = m_myMap.find(some_key_string);
if(i == m_imagesMap.end())
return NULL;
string *p = &i->first;
Run Code Online (Sandbox Code Playgroud)
最后一行有效吗?我想将这个指针p存储在其他地方,它对整个程序生命有效吗?但是如果我向这个地图添加更多元素(使用其他唯一键)或删除其他一些键会发生什么情况呢,它不会重新分配这个字符串(键值对),那么p将变为无效?