As a special case of that, you can even have a shared_ptr that returns 0 from get() yet manages the lifetime of something.
On Saturday, September 17, 2011, Frank Mori Hess <fmhess@speakeasy.net> wrote:
> On Saturday, September 17, 2011, John M. Dlugosz wrote:
>> I guess that is what I'm trying to figure out.
>> If two smart pointers manage the lifetime of the same entity, how can
>> they not get() the same pointer? I see that they might be different
>> addresses if they refer to the object by different types, but that is
>> true for regular pointers, and bringing them to a common base class
>> would allow them to compare equal.
>
> shared_ptr also has an aliasing copy constructor, where you can give it an
> arbitrary pointer. So, you might make a shared_ptr that points at a struct
> and a shared_ptr that points at a member of the same struct, but they both
> share the same reference count and deleter.
>
>