Boost logo

Boost :

Subject: Re: [boost] [shared_ptr] delete shared_ptr
From: Julian Gonggrijp (j.gonggrijp_at_[hidden])
Date: 2011-03-18 06:05:04


Nevin Liber wrote:

> On 17 March 2011 13:53, pavel <paul.cpprules_at_[hidden]> wrote:
>
>> it deletes or otherwise releases guarded resource only if no other
>> smart pointer holds a reference to the resource
>
> Yes, we know what reset does. You haven't given an argument as to why
> delete should do the same thing, and we've given you reasons why it isn't a
> good idea.

+1

If you want to say that a specific smart pointer has no interest in
the pointee anymore, I think the expression p = 0; covers those
semantics better. I don't know whether the current Boost.Smart_Ptr
implementation supports that syntax, but it might be a nice addition.
(I.e., p = 0; means the same as p.reset();.)

delete p; really suggests that the pointee is going to be destroyed,
so if that's not what you intend you shouldn't use the syntax.

-Julian


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