> On 6/16/07, michael.a <[EMAIL PROTECTED]> wrote: > > > > As for "placement new", from what I can find, it is unsafe to use with any > > memory that isn't part of the heap. > Huh????? It can be used with stack variables, we have tests in the > testsuite where we use it with such. > > > As for the discussion of unions, placement new is way too much overhead. > > placement new has no overhead, that is by design. I literally mean > placement new does nothing except for changing the dynamic type and > calling the constructor. Where is the overhead there? I see unions > having more overhead than placement new as unions are not as well > optimized.
... And when the said constructor is trivial (e.g. for POD), then you pay nothing, zilch, nada. (same with placement delete) In C++, some things you write (od don't write) are merely abstractions for what should happen, which can represent 'nothing'. Only if you ask for pessimized code can you possibly pay function call overheads on de-inlined empty functions. Fang