Boost logo

Boost :

From: David B. Held (dheld_at_[hidden])
Date: 2002-12-04 13:04:13


"Eric Woodruff" <Eric.Woodruff_at_[hidden]> wrote in message
news:aslbsn$nt3$1_at_main.gmane.org...
> [snip]
>
> > holder<Foo> h;
> > new (h.storage) Foo;
>
> What is the meaning of that syntax?

This is placement new syntax. It means construct a Foo at the address
h.storage, without allocating any memory.

> > ...
> > T* u = dangerous_cast<T*>(h.storage); // can't do this with
> > reinterpret_cast
>
> Why would you want to do that in the first place.

Because you want to get at the T in h in a portable way. Which brings
me to my next point. Since it seems this is the only context in which this
cast is guaranteed to give a meaningful result, maybe it should be called
placement_cast<>?

Dave


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