Boost logo

Boost :

From: Eric Woodruff (Eric.Woodruff_at_[hidden])
Date: 2002-12-04 13:43:34


"David B. Held" <dheld_at_[hidden]> wrote in message
news:aslftb$cr2$1_at_main.gmane.org...
> "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.
>

So the type really is of Foo, which has to mean that casting h.storage back
to a Foo* using reinterpret_cast is covered by the standard.

> > > ...
> > > 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
>
>
>
>
> _______________________________________________
> Unsubscribe & other changes:
http://lists.boost.org/mailman/listinfo.cgi/boost
>


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