Boost logo

Boost Users :

Subject: Re: [Boost-users] shared_ptr design question
From: Emil Dotchevski (emil_at_[hidden])
Date: 2011-09-17 13:32:08

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_at_[hidden]>
> 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
> and a shared_ptr that points at a member of the same struct, but they both
> share the same reference count and deleter.

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at