I have a std::list from boost::shared_ptr<T> and I want to remove an element from it, but I only have a pointer of type T * that corresponds to one of the elements in the list.
However, I cannot use myList.remove( tPtr ) I assume, because shared_ptr does not implement == for its type of template argument.
I immediately thought about trying myList.remove( shared_ptr<T>(tPtr) ) , which is syntactically correct, but it will exit double deletion, since the temporary shared_ptr has a separate use_count.
std::list< boost::shared_ptr<T> > myList; T* tThisPtr = new T();
The only options I see for the rest are using std :: find with a custom comparison or cycling around the list and searching for it yourself, but it seems like there should be a better way.
Am I missing something obvious or is it too substandard use to remove the clean / regular way?
source share