Subject: Re: [boost] [interest] rich-typed smart pointers
From: Julian Gonggrijp (j.gonggrijp_at_[hidden])
Date: 2013-10-07 04:34:39
Larry Evans wrote:
>> 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.
> When the attached dangling_ptr.cpp driver is run (using the
> also attached obj_id.cpp), the output (last attachment)
> indicates the weak_ptr is accessing a dangling pointer.
> Refcounted smart pointers (such as boost::shared_ptr),
> would not allow that, IIUC.
> Am I missing something?
No, you are not missing anything. In this respect the rtp pointers
behave rather like std::unique_ptr with std::unique_ptr::get. Jeremy
Maitin-Shepard was right to point out that the name rtp::weak_ptr is
misleading for this reason. I will clear up the confusion and be more
explicit about the risks in the next alpha version.
Thanks again for the effort!
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk