Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2003-10-15 09:11:48


Ehsan Akhgari wrote:

>>-----Original Message-----
>>From: David Abrahams
>>
>>"Ehsan Akhgari" <ehsan_at_beginth read.zl6writes
>>
>>
>>>int main()
>>>{
>>> void * pv = custom_alloc( sizeof(X) ); // allocate
>>> X * p = new( pv ) X; // create
>>> delete( pv, p ); // destroy
>>
>>I think this should be, simply,
>>
>> p->~X();
>>
>>
>>
>>> custom_dealloc( p ); // deallocate
>>>}
>
>
> They do the same thing. Placement delete is just a no-op, and the fact
> that the compiler sees the delete keyword causes it to silently invoke
> the dtor, and then call the delete function (which is a no-op). I think
> the placement delete syntax is neater and more in sync with the
> placement new, though I myself sometimes call the dtor explicitly. This
> is mostly a matter of style and taste.

Last I recall, you can't use placement delete syntax to call the d'tor.
But I may be misremembering.


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