Boost logo

Boost :

From: Ehsan Akhgari (ehsan_at_[hidden])
Date: 2003-10-14 23:11:49


> -----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.

-------------
Ehsan Akhgari

List Owner: MSVC_at_[hidden]

[ Email: ehsan_at_[hidden] ]
[ WWW: http://www.beginthread.com/Ehsan ]


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