0

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!

domlao
  • 15,663
  • 34
  • 95
  • 134

0 Answers0