$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [boost] [shared_ptr] delete shared_ptr
From: Kenny Riddile (kfriddile_at_[hidden])
Date: 2011-03-18 12:11:42
On 3/18/2011 11:00 AM, Eric J. Holtman wrote:
> On 3/18/2011 8:44 AM, Kenny Riddile wrote:
>
>>
>> But it doesn't state that intention at all.  The intention it very
>> clearly states is that something *is* being deleted.  The word "delete"
>> has a very specific meaning in the English language.  Assigning the
>> shared_ptr to null or to another shared_ptr tracking a different object
>> *does* state that intention, but "delete p;" and "p = 0;" are not, and
>> should not, be the same.
>>
>
> I have to chime in and agree here.
>
> having "delete p" do *anything other* than p = 0
> for a smart pointer would be suicidal.
That actually kind of sounds like the exact opposite of what I said :)
What I said was that assigning any type of pointer to a new value 
signifies that you don't care about being able to access the previous 
value via that pointer.
Calling delete on a pointer can only signify that you want to delete 
what that pointer points to.  Since every call to shared_ptr::reset() 
doesn't result in a deletion, it is inappropriate to equate them. 
"reset" and "delete" do not mean the same thing in the context of a 
handle to a shared resource, like shared_ptr.