weak_ptr for intrusive_ptr's??

Is there an weak_ptr<> equivalent to the intrusive_ptr<>, to handle ownership cycles? Thanks.

Edson Tadeu wrote:
Is there an weak_ptr<> equivalent to the intrusive_ptr<>, to handle ownership cycles?
Nope. To make a safe weak_ptr, one must mantain the count seperately, in which case you might as well be using shared_ptr, as that's just what that does. If you don't care for safety (by which I mean, you know you won't use your "weak" pointers when the object is dead) you might as well just use a raw pointer. A similar post which covers the same topic: http://lists.boost.org/MailArchives/boost/msg40413.php This post also covers creating a shared_ptr from an intrusive_ptr, which could in turn be used to create weak_ptr objects if you really need them - but the pointee will be considered "destroyed" by the weak_ptrs when that series of shared_ptrs is destroyed, rather than when it actually is. -Mike
participants (2)
-
Edson Tadeu
-
Michael B. Edwin Rickert