A declaration of a placement deallocation function matches the
declaration of a placement allocation function if it has the same number
of parameters and, after parameter transformations (
[dcl.fct]), all
parameter types except the first are identical
. If
the lookup finds a single matching deallocation function, that function
will be called; otherwise, no deallocation function will be called
. If
the lookup finds a usual deallocation
function
and that function,
considered as a placement deallocation function, would have been
selected as a match for the allocation function, the program is
ill-formed
. For a non-placement allocation function, the normal deallocation
function lookup is used to find the matching deallocation
function (
[expr.delete])
. In any case,
the matching deallocation function (if any) shall be non-deleted and
accessible from the point where the
new-expression appears
. [
Example 7:
struct S {
static void* operator new(std::size_t, std::size_t);
static void operator delete(void*, std::size_t);
};
S* p = new (0) S;
—
end example]
If a
new-expression calls a deallocation function, it passes
the value returned from the allocation function call as the first
argument of type
void*. If a placement deallocation function is
called, it is passed the same additional arguments as were passed to the
placement allocation function, that is, the same arguments as those
specified with the
new-placement syntax
. If the implementation is allowed
to introduce a temporary object or make a copy of any argument
as part of the call to the allocation function,
it is unspecified whether the same object is used in the call
to both the allocation and deallocation functions
.