[basic.stc.dynamic.deallocation]

# 6 Basics [[basic]](./#basic)

## 6.8 Memory and objects [[basic.memobj]](basic.memobj#basic.stc.dynamic.deallocation)

### 6.8.6 Storage duration [[basic.stc]](basic.stc#dynamic.deallocation)

#### 6.8.6.5 Dynamic storage duration [[basic.stc.dynamic]](basic.stc.dynamic#deallocation)

#### 6.8.6.5.3 Deallocation functions [basic.stc.dynamic.deallocation]

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L4547)

A deallocation function that is not a class member function
shall belong to the global scope and not have a name with internal linkage[.](#1.sentence-1)

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L4552)

A deallocation function
is a [*destroying operator delete*](#def:operator_delete,destroying "6.8.6.5.3 Deallocation functions [basic.stc.dynamic.deallocation]") if it has at least two parameters
and its second parameter
is of type std​::​destroying_delete_t[.](#2.sentence-1)

A destroying operator delete
shall be a class member function named operator delete[.](#2.sentence-2)

[*Note [1](#note-1)*:

Array deletion cannot use a destroying operator delete[.](#2.sentence-3)

â *end note*]

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L4564)

Each deallocation function shall return void[.](#3.sentence-1)

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*[.](#3.sentence-2)

A deallocation function may have more
than one parameter[.](#3.sentence-3)

A [*usual deallocation function*](#def:usual_deallocation_function "6.8.6.5.3 Deallocation functions [basic.stc.dynamic.deallocation]") is a deallocation function
whose parameters after the first are

- [(3.1)](#3.1)

optionally, a parameter of type std​::​destroying_delete_t, then

- [(3.2)](#3.2)

optionally, a parameter of type std​::​size_t,[24](#footnote-24 "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]).") then

- [(3.3)](#3.3)

optionally, a parameter of type std​::​align_val_t[.](#3.sentence-4)

A destroying operator delete shall be a usual deallocation function[.](#3.sentence-5)

A deallocation function may be an instance of a function
template[.](#3.sentence-6)

Neither the first parameter nor the return type shall depend
on a template parameter[.](#3.sentence-7)

A deallocation
function template shall have two or more function parameters[.](#3.sentence-8)

A template
instance is never a usual deallocation function, regardless of its
signature[.](#3.sentence-9)

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L4600)

If a deallocation function terminates by throwing an exception, the behavior is undefined[.](#4.sentence-1)

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[.](#4.sentence-2)

[5](#5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L4606)

If the argument given to a deallocation function in the standard library
is a pointer that is not the null pointer value ([[basic.compound]](basic.compound "6.9.4 Compound types")), the
deallocation function shall deallocate the storage referenced by the
pointer, ending the duration of the region of storage[.](#5.sentence-1)

[24)](#footnote-24)[24)](#footnoteref-24)

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]](diff.cpp11.basic "C.5.3 [basic]: basics"))[.](#footnote-24.sentence-1)
