Anirban Saha
Anirban Saha

Reputation: 149

Delete a specific entry by key in a map. std::unordered_map<const char*,std::vector<int>> mp;

I am doing like this :

auto find = mp.find(key); if(find != mp.end()) mp.erase(find);

Will the above delete the whole vector as well corresponding to the key?

Upvotes: 1

Views: 127

Answers (1)

Marshall Clow
Marshall Clow

Reputation: 16670

The call to erase will destroy both the key and the value for the entry in the map.

So yes, it will destroy the vector as well.

Upvotes: 2

Related Questions