|
Boost : |
Subject: Re: [boost] [shared_ptr] delete shared_ptr
From: Kenny Riddile (kfriddile_at_[hidden])
Date: 2011-03-17 15:08:51
On 3/17/2011 2:13 PM, pavel wrote:
> and at last can you please give a couple of reasons why delete'ing
> smart pointers is a bad idea?
Because it's a lie. "delete" should delete something, and not be
overloaded to perform non-obvious, unrelated logic. A perfect example
is how the proposed usage of "delete" confused Frank Mori Hess. Was it
unreasonable for him to see "delete" and assume that it was actually
deleting something?
On 3/17/2011 2:13 PM, pavel wrote:
> furthermore this can simplify template programming
> here is an example
>
> template<typename ptr_t>
> void takes_ownership(ptr_t p)
> {
> //do something with the data
> delete p;
> }
The same can be accomplished using type traits or function overloading.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk