$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [boost] Looking for thoughts on a new smart pointer: shared_ptr_nonnull
From: Julian Gonggrijp (j.gonggrijp_at_[hidden])
Date: 2013-10-02 13:48:20
Andrey Semashev wrote:
> Anyway, I think, such a pointer does not behave like a real pointer,
> so it shouldn't be called as such. It looks more like a reference,
> except that the referred object is accessed through operator->. Maybe
> it should be called shared_ref because of it. Thinking about it this
> way, there is no need for reset() or constructors from pointers - only
> assignment, emplace() and forwarding constructors. Interoperability
> with shared_ptr can be provided as an extension (maybe with free
> functions), but that would be just an extension, i.e. no implicit
> conversion.
I respectfully disagree. A reference is much more restricted than a
smart pointer that cannot be null: it cannot change reference and it
never owns the object it references. In summary, it mostly has the
semantics of a second name to a previously created object. Smart
pointers that cannot be null have exactly the same range of semantics
and syntactical appearance as other pointers, except for the guarantee
of not being null.
-Julian