When you =delete execute a function, you actually delete its definition.
8.4.3 Deleted Definitions [dcl.fct.def.delete]
1 Definition of a function of the form:
specifier attribute-seqopt decl-specifier-seqopt declarator = delete;
called remote definition. A function with a remote definition is also called a remote function.
But by doing so you also declare this function. Quoting from the standard [1] :
4 The remote function is implicitly built-in. [Note. A single definition rule (3.2) applies to remote definitions. -end note] Remote function definition should be the first function declaration [...]
And therefore, by making a = A() , the compiler actually resolves A::operator=(A&&) because it was declared (not A::operator(const A&) , because A&& is “more binding” to r-values ) However, when its definition is deleted, the line is poorly formed.
2 A program that refers to a remote function implicitly or explicitly, except for the declaration, is poorly formed.
[1] The tone of the underlined sentence is really necessary here. The standard states that a function declaration =delete d must first appear before other declarations. However, it supports the fact that deleting a function also declares a function.
Mark Garcia 09 Oct '13 at 8:00 2013-10-09 08:00
source share