Quote Originally Posted by laserlight View Post
Yes, but how does that conflict with what I stated? My understanding is that placement new is used in the standard allocator's construct member function.
Internally, it may be... creating an object involves two steps:

1) "Selecting" (for lack of a better word) a memory address or contigous block for items with sizeof()>1. This can be on the stack, dynamically aquired from the allocator (by default on the general heap), or specified by the caller.

2) Invoking the constructor, passing the effective base of this memory as the this pointer.

Of the three:
1) Memory on the stack
2) Memory allocated at the time of the call
3) Memory with the address specified.

Only the second one is relevant to any discussion about performance (how long it takes and how much memory is consumed). Condition #1 is a fixed compile time offset from the stack pointer, and Condition #3 is a parameter passed to a routine.

In psuedo code, this may be:
Code:
*Object New()
{
     *Memory = AllocateMemory();
     *Object = InvokeConstructor(*Memory);
}

*Object PlacementNew(*Memory )
{
     *Object = InvokeConstructor(*Memory);
}
Or may be:
Code:
*Object New()
{
     *Memory = AllocateMemory();
     *Object = PlacementNew(*Memory);
}

*Object PlacementNew(*Memory )
{
     *Object = InvokeConstructor(*Memory);
}
The latter is likely to be a common implementation. But the impact of replacing the allocator (either on a per-class basis, or globally) is to replace the psuedo-"AllocateMemory()" functionallity.