Boost logo

Boost :

Subject: Re: [boost] Looking for thoughts on a new smart pointer: shared_ptr_nonnull
From: Thorsten Ottosen (thorsten.ottosen_at_[hidden])
Date: 2013-10-09 02:09:55


On 09-10-2013 00:44, Gavin Lambert wrote:
> On 10/9/2013 3:26 AM, Quoth Thorsten Ottosen:

>> I suppose there is still a need to break cycles. Why would this have
>> changed.
>
> But part of the semantics of weak_ptr is that it can point to a
> non-existent (expired) object, which is effectively the same as a null
> one. And lock() must be able to return an empty pointer, so it would
> have to be a regular shared_ptr<T> rather than a
> shared_ptr<*_non_null<T>>. So I'm not sure if a weak_ptr<*_non_null<T>>
> could make sense.

Or lock() could return something else. Anyway, it could be that just
reusing the normal weak ptr would be good.

-Thorsten


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk