If I have a vector<weak_ptr<Type>>
, I cannot use vector::erase(remove())
to remove the required weak_ptr
, because it does not have a comparison operator==.
A lambda predicate has to be passed to remove_if
in vector::erase(remove_if())
comparing the underlying raw pointers accessed via weak_ptr::_Get()
The _Get()
begins with an underscore and a capital letter meaning that it's reserved for the implementation and isn't meant to be accessed by the user.
It's clear that weak_ptr
s were not meant to be stored this way, but why?
I was thinking of using a vector<weak_ptr<>>
to hold weak_ptr
s in a child class of only some of the objects I have in the manager class that need further processing and thus assure, by lock()
ing, that they have not been deleted in the managing class (in a multithreaded application).
The manager alerts the child class of object creation and deletion, keeping the vector<weak_ptr<>>
up-to-date.