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-02 09:01:28


On 02-10-2013 00:54, Luke Bradford wrote:
> Hi,
>
> I'm new to this list, so apologies for any oversights or faux pas.
>
> I've been finding a lot of use for a type of smart pointer I call
> shared_ptr_nonnull, which is a variation on shared_ptr which is never
> allowed to be empty. Specifically:
>
> (1) It doesn't have reset() with no arguments, doesn't have a default
> constructor, and doesn't have implicit conversion to bool (which would
> always be true.)
> (2) It throws an exception whenever there's an attempt to make it empty,
> i.e. in constructors, reset, assignment, and swap.

A few comments:

a) swap would always work because both arguments must be non-null.

b) this smart pointer cannot be moved (no move-assignment, no
move-constructor).

Otherwise, I have often had a use for such a smart pointer.

-Thorsten


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