Boost logo

Boost :

Subject: Re: [boost] [SmartPointers] Determine interest in a new pointer wrapper class "flex_ptr"
From: Josh Juran (jjuran_at_[hidden])
Date: 2015-03-27 16:28:32


On Mar 27, 2015, at 1:16 PM, Gottlob Frege <gottlobfrege_at_[hidden]> wrote:

> On Wed, Mar 25, 2015 at 8:55 AM, Jakob Riedle <jakob.riedle_at_[hidden]> wrote:
>>> A null-deleter would make it basically non-owning..
>>
>> That doesn't solve Efficiency, but it allows for non-owning shared_ptr's.
>> Thank you!
>
> It doesn't, however, solve the underlying safety issues. Smart
> Pointers tend to be smart in two ways:
>
> - track ownership to correctly delete object
> - be safe
>
> With flex_ptr (or shared_ptr with custom deleter), how do you know
> that a non-null flex_ptr is pointing to valid memory or not.
> Or if it is valid on this line, but not the next, due to threading or something.

Consider using boost::intrusive_ptr. You can remove the object from intrusive_ptr's management by calling intrusive_ptr_add_ref() on it manually, and return it by calling intrusive_ptr_release().

Josh


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