Quick A: No, but unordered_map<string, unique_ptr<MyClass>>::erase and unordered_map<string, shared_ptr<MyClass>>::erase do.
Today on SO:
std::unordered_map<std::String, myClass*>-- doesstd::unordered_map::erase()callmyClass' DTor?Assume I have some
unordered_mapof pointers to class instances, would erasing an object from that map also delete the instance?(rewording the question:) If I wanted to delete that instance, which version would be right?
if(it != map.end()) { delete it->second; map.erase(it); }or simply
if(it != map.end()) map.erase(it);?

Add a Comment
Comments are closed.