Boost logo

Boost :

Subject: Re: [boost] [interest] rich-typed smart pointers
From: Larry Evans (cppljevans_at_[hidden])
Date: 2013-10-05 16:10:33


On 10/02/13 13:34, Julian Gonggrijp wrote:
> Dear Boost members,
>
> I have designed a smart pointer that relies on the type system to
> offer safe and flexible automatic memory management at no runtime
> cost. It combines single ownership as in std::unique_ptr and reliable
> access from multiple places as in std::shared_ptr with some additional
> features. I believe it to be about as safe and practically useful as a
> smart pointer in C++11 could get.
>
> Further explanation and a proof-of-concept implementation is available
> over here:
>
> https://github.com/jgonggrijp/rich-typed-pointers
>
[snip]
If there were a templated owned_ptr CTOR:

     template<typename Derived>
     owner_ptr (owner_ptr<Derived> && source) : pointer(source.pointer) {
         source.pointer = nullptr;
     }

wouldn't that eliminate the need for the make_dynamic templated function?

Just wondering. I haven't tried it, but I'd guess it would work because
the ownd_ptr<Derived> could be constructed with the:

   make<Derived>(t1,t2,...tn)

and then the templated owned_ptr CTOR would then convert that to the
base class?

-regards,
Larry


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