domlao
domlao

Reputation: 16029

Erasing Item In std::map with scoped_ptr

Is it safe to remove an item in a std::map with scoped_ptr? Lile,

std::map<std::string, boost::scoped_ptr<CFoo*>> lmap;

boost::scoped_ptr<CFoo> item1(new CFoo);
boost::scoped_ptr<CFoo> item2(new CFoo);

lmap["item1"] = item1;
lmap["item2"] = item2;


std::map<std::string, boost::scoped_ptr<CFoo*>>::iterator iter;
iter = lmap.find("item1");
lmap.erase(iter)

Thanks!

Upvotes: 0

Views: 160

Answers (0)

Related Questions