[dcl.fct.def.delete]

# 9 Declarations [[dcl]](./#dcl)

## 9.6 Function definitions [[dcl.fct.def]](dcl.fct.def#delete)

### 9.6.3 Deleted definitions [dcl.fct.def.delete]

[1](#1)

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

A [*deleted definition*](#def:definition,deleted "9.6.3 Deleted definitions [dcl.fct.def.delete]") of a function is a function definition
whose [*function-body*](dcl.fct.def.general#nt:function-body "9.6.1 General [dcl.fct.def.general]") is a [*deleted-function-body*](dcl.fct.def.general#nt:deleted-function-body "9.6.1 General [dcl.fct.def.general]") or an explicitly-defaulted definition of the function where the function is
defined as deleted[.](#1.sentence-1)

A [*deleted function*](#def:function,deleted "9.6.3 Deleted definitions [dcl.fct.def.delete]") is
a function with a
deleted definition or a function that is implicitly defined as deleted[.](#1.sentence-2)

[2](#2)

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

A construct that designates a deleted function implicitly or explicitly,
other than to declare it or to appear as the operand of
a [*reflect-expression*](expr.reflect#nt:reflect-expression "7.6.2.10 The reflection operator [expr.reflect]") ([[expr.reflect]](expr.reflect "7.6.2.10 The reflection operator")),
is ill-formed[.](#2.sentence-1)

*Recommended practice*: The resulting diagnostic message should include
the text of the [*unevaluated-string*](lex.string.uneval#nt:unevaluated-string "5.13.6 Unevaluated strings [lex.string.uneval]"),
if one is supplied[.](#2.sentence-2)

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

This includes calling the function
implicitly or explicitly and forming a pointer or pointer-to-member to the
function[.](#2.sentence-3)

It applies even for references in expressions that are not
potentially-evaluated[.](#2.sentence-4)

For an overload set, only the
function selected by overload resolution is referenced[.](#2.sentence-5)

The implicit
odr-use ([[basic.def.odr]](basic.def.odr#term.odr.use "6.3 One-definition rule")) of a virtual function does not, by itself,
constitute a reference[.](#2.sentence-6)

The [*unevaluated-string*](lex.string.uneval#nt:unevaluated-string "5.13.6 Unevaluated strings [lex.string.uneval]"), if present,
can be used to explain the rationale for deletion and/or
to suggest an alternative[.](#2.sentence-7)

â *end note*]

[3](#3)

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

[*Example [1](#example-1)*:

One can prevent default initialization and
initialization by non-doubles withstruct onlydouble { onlydouble() = delete; // OK, but redundanttemplate<class T> onlydouble(T) = delete;
 onlydouble(double);};

â *end example*]

[*Example [2](#example-2)*:

One can prevent use of a
class in certain [*new-expression*](expr.new#nt:new-expression "7.6.2.8 New [expr.new]")*s* by using deleted definitions
of a user-declared operator new for that class[.](#3.sentence-2)

struct sometype {void* operator new(std::size_t) = delete; void* operator new[](std::size_t) = delete;};
sometype* p = new sometype; // error: deleted class operator new sometype* q = new sometype[3]; // error: deleted class operator new[] â *end example*]

[*Example [3](#example-3)*:

One can make a class uncopyable, i.e., move-only, by using deleted
definitions of the copy constructor and copy assignment operator, and then
providing defaulted definitions of the move constructor and move assignment operator[.](#3.sentence-3)

struct moveonly { moveonly() = default;
 moveonly(const moveonly&) = delete;
 moveonly(moveonly&&) = default;
 moveonly& operator=(const moveonly&) = delete;
 moveonly& operator=(moveonly&&) = default; ~moveonly() = default;};
moveonly* p;
moveonly q(*p); // error: deleted copy constructor â *end example*]

[4](#4)

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

A deleted function is implicitly an inline function ([[dcl.inline]](dcl.inline "9.2.8 The inline specifier"))[.](#4.sentence-1)

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

The
one-definition rule ([[basic.def.odr]](basic.def.odr "6.3 One-definition rule")) applies to deleted definitions[.](#4.sentence-2)

â *end note*]

A deleted definition of a function shall be the first declaration of the function or,
for an explicit specialization of a function template, the first declaration of that
specialization[.](#4.sentence-3)

An implicitly declared allocation or deallocation function ([[basic.stc.dynamic]](basic.stc.dynamic "6.8.6.5 Dynamic storage duration"))
shall not be defined as deleted[.](#4.sentence-4)

[*Example [4](#example-4)*: struct sometype { sometype();};
sometype::sometype() = delete; // error: not first declaration â *end example*]
