Boost logo

Boost :

Subject: [boost] deleting smart pointer (was [shared_ptr] delete shared_ptr)
From: pavel (paul.cpprules_at_[hidden])
Date: 2011-03-18 13:08:56


 Sid wrote on Friday, March 18, 2011 at 9:40:52:
> I don't necessarily agree that it's a lie.

> I think it's simply stating an intention; the intention being that
> the current shared pointer is no longer interesting in the shared
> object; who cares if the shared object gets deleted under the
> covers. This is the mentality that one needs to have in a
> garbage-collected environment, since you get the same exact effect when you set a reference to null.

> Having said that; I don't yet feel Pavel has convinced me that
> changing the shared_pr library will buy anything significant.

you got exactly my point!

since for example 'smart_ptr' claims to be a pointer AND it allows
such horrible thing like

  p = 0; //'p.reset()' is implied??

why shouldn't it be 'delete'ed?
the 'delete' operation does much less harm than that null assignment

otherwise it should be named like 'shared_guard' or something

and the semantics of deletion is well defined in the case of smart
pointer, which states "i don't want the data pointed to anymore"
(excuse me for repetition)

eventually the user has done the duty 'delete'ing the data and
generally doesn't care if the data gets deleted immediately or when
all other references quit

sorry for not replying every message, i hope this answers all those
questions

-- 
Pavel
P.S.
if you notice a grammar mistake or weird phrasing in my message
please point it out

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