[basic.stc.dynamic.deallocation] (original) (raw)

6 Basics [basic]

6.7 Memory and objects [basic.memobj]

6.7.6 Storage duration [basic.stc]

6.7.6.5 Dynamic storage duration [basic.stc.dynamic]

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

A deallocation function that is not a class member function shall belong to the global scope and not have a name with internal linkage.

A deallocation function is a destroying operator deleteif it has at least two parameters and its second parameter is of type std​::​destroying_delete_t.

A destroying operator delete shall be a class member function named operator delete.

[Note 1:

Array deletion cannot use a destroying operator delete.

— _end note_]

Each deallocation function shall return void.

If the function is a destroying operator delete declared in class type C, the type of its first parameter shall be C*; otherwise, the type of its first parameter shall be void*.

A deallocation function may have more than one parameter.

A usual deallocation function is a deallocation function whose parameters after the first are

A destroying operator delete shall be a usual deallocation function.

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.

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 ([basic.compound]), the deallocation function shall deallocate the storage referenced by the pointer, ending the duration of the region of storage.