Boost logo

Boost :

Subject: Re: [boost] deleting smart pointer
From: Stewart, Robert (Robert.Stewart_at_[hidden])
Date: 2011-03-21 07:06:19


pavel wrote:
> Steven wrote on Saturday, March 19, 2011 at 1:31:51:
>
> >> rephrasing your words: how is 'delete p' a bad idea? it's
> >> obvious it is almost like 'p.reset()'
>
> > No it isn't. The difference is that assignment
> > is a basic operation for a smart_ptr, and it's
> > behaving in the normal way. It isn't a matter
> > of being "almost like" reset.
>
> i see your point but you don't want to see mine

There's a difference between seeing another's point and agreeing with it. Steven understands your proposal just fine from what I've read in the discussion.

> here is the full citation of 5.3.5.2 of ISO/IEC 14882:2003(E) which,
> i guess, you are referring to:
>
> "If the operand has a class type, the operand is converted to
> a pointer type by calling the above-mentioned conversion
> function, and the converted operand is used in place of the
> original operand for the remainder of this section. In either
> alternative, if the value of the operand of delete is the null
> pointer the operation has no effect. In the first alternative
> (delete object), the value of the operand of delete shall be a
> pointer to a non-array object or a pointer to a sub-object
> (1.8) representing a base class of such an object (clause 10).
> If not, the behavior is undefined."

IOW, a shared_ptr sp must provide an implicit conversion to T * in order for delete sp to work, because delete only operates on T *'s, which then introduces an unwanted implicit conversion in shared_ptr.

_____
Rob Stewart robert.stewart_at_[hidden]
Software Engineer using std::disclaimer;
Dev Tools & Components
Susquehanna International Group, LLP http://www.sig.com

IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.


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