Say I have 2 containers storing pointers to the same objects...
std::list<Foo*> fooList;
std::vector<Foo*> fooVec;
Lets say I remove an object from one of these containers via one if its methods, for example...
std::vector<Foo*>::iterator itr =
std::find( fooVec.begin(), fooVec.end(), pToObj );
fooVec.erase( itr );
CppReference says that this calls the object's destructor. Does this mean that the pointer to the object in fooList is a dangling pointer?
I'd prefer not to use reference counted pointers. How can this problem be handled?