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-07 05:48:15

On 05-10-2013 12:18, Rob Stewart wrote:
> On Oct 4, 2013, at 1:38 PM, Matt Calabrese <rivorus_at_[hidden]> wrote:

>> I'll repeat my basic, underlying stance here for people to agree/disagree with. A non-null shared_ptr should be exactly that. It should have the same
>> or extremely similar interface to a shared_ptr (including things like bool-conversion), just with more strict invariants and preconditions. This makes drop-in replacement and use in generic functions easier to deal with and also avoids sacrificing additional functionality that shared_ptr provides. People shouldn't have to avoid switching to a non-null shared
>> pointer simply because they have no way of constructing it with a pointer that they obtained from a factory.

If the idea is to be 100% shared_ptr interface compatible, it may be
easier just to extend boost::shared_ptr a little:

   typedef boost::shared_ptr<boost::non_nullable<T>> SharedT;
   typedef boost::shared_ptr<boost::non_nullable<T>> WeakT;


Boost list run by bdawes at, gregod at, cpdaniel at, john at