I have a std::multiset of objects (created in place with set::emplace). This gives me sorted access using a custom comparator.
The objects themselves also contain a list of pointers to other objects that identify some dependencies (the dependencies are not used in the comparator and do not affect the underlying tree structure of the set). Currently this dependency list is implemented as an std::list of raw object pointers. This is unsafe, however, because a dependency could be removed from the multiset without the objects holding these dependency pointers being notified.
Is there a way to use weak_ptr to point to the objects in the set without using shared_ptrs in the set itself? Or is the only way to accomplish this to have a set of share_ptrs instead of Objects?