I believe the problem may stem 开发者_开发问答from using boost::shared_ptrs as key values.
//header file:
#include <map>
std::map<boost::shared_ptr<foo>, bar> myMap; // Private member variable
//////////
myMap.insert(pair);
//////////
myMap.clear()
Neither foo nor bar are abstract classes. At which point, during run-time, I will receive a "pure virtual method called" error, and my program will terminate. I've also tried iterating through the map and using myMap.erase(iterator), which produces the same error.
If bar is a polymorphic type, when you it could be slicing the class. Depending on what the destructor is doing, it could then access a pure virtual method.
精彩评论