3 Basic concepts [basic]

3.7 Storage duration [basic.stc]

3.7.4 Dynamic storage duration [basic.stc.dynamic]

3.7.4.2 Deallocation functions [basic.stc.dynamic.deallocation]

Deallocation functions shall be class member functions or global functions; a program is ill-formed if deallocation functions are declared in a namespace scope other than global scope or declared static in global scope.

Each deallocation function shall return void and its first parameter shall be void*. A deallocation function may have more than one parameter. A usual deallocation function is a deallocation function that has:

  • exactly one parameter; or

  • exactly two parameters, the type of the second being either std::align_val_t or std::size_t39; or

  • exactly three parameters, the type of the second being std::size_t and the type of the third being std::align_val_t.

A deallocation function may be an instance of a function template. Neither the first parameter nor the return type shall depend on a template parameter. [ Note: That is, a deallocation function template shall have a first parameter of type void* and a return type of void (as specified above).  — end note ] A deallocation function template shall have two or more function parameters. A template instance is never a usual deallocation function, regardless of its signature.

If a deallocation function terminates by throwing an exception, the behavior is undefined. The value of the first argument supplied to a deallocation function may be a null pointer value; if so, and if the deallocation function is one supplied in the standard library, the call has no effect.

If the argument given to a deallocation function in the standard library is a pointer that is not the null pointer value ([conv.ptr]), the deallocation function shall deallocate the storage referenced by the pointer, ending the duration of the region of storage.

The global operator delete(void*, std::size_t) precludes use of an allocation function void operator new(std::size_t, std::size_t) as a placement allocation function ([diff.cpp11.basic]).