Boost logo

Boost Users :

From: Noah Roberts (roberts.noah_at_[hidden])
Date: 2008-05-18 00:43:57


Jose Martinez wrote:
>> It gets initialized by the shared_ptr constructor.
>
> Frank, when I call user_count() on the _internal_weak_ptr before calling share_from_this() I get back 1. So are you referring to the first shared_ptr constructor in main() (vs the constructor in share_from_this())? If so how is it initialized? The shared_ptr constructor gets passed a reference to the object being pointed, are you saying it goes and searches out for _internal_weak_ptr within that object and initializes it if it finds it?
>

I don't know how it works, I've not looked at it, but it wouldn't have
to "search" for the data you are referring to. To enable the features
you are talking about you have to subclass a specific object, correct?
enable_shared_from_this. Well, there you have it! All the shared_ptr
would have to do in order to know that it's enabled is to have a special
constructor for objects inheriting from that object or to examine the
inheritance tree with some metafunctions in the templated constructor.

My bet is on the latter.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net