map<string ,vector<void*>> mymap;
我试过了,
std::map<std::string, vector<void*>>::iterator itr = mymap.begin();
std::vector<void*> ::iterator it =(itr->second).begin();
if(it != (itr->second).end())
{
(itr->second).resize(0);
(itr->second).shrink_to_fit();
}
mymap.clear();
答案 0 :(得分:0)
我真的不明白这个问题,但是如果你想要删除vector<void*>
指向的对象,那么使用:
for (const auto& v : mymap) //for each value in the map
for (const auto& address: v.second) //for each element in the vector
delete address;
mymap.clear ();