This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 119a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2025-12-20
[Voted into WP at March, 2010 meeting.]
The only restriction placed on the use of “=default”in 9.6 [dcl.fct.def] paragraph 9 is that a defaulted function mustbe a special member function. However, there are many variations ofdeclarations of special member functions, and it's not clear which ofthose should be able to be defaulted. Among the possibilities:
default arguments
by-value parameter for a copy assignment operator
exception specifications
arbitrary return values for copy assignment operators
aconst reference parameter when the implicitfunction would have a non-const
Presumably, you should only be able to default a function if itis declared compatibly with the implicit declaration that would havebeen generated.
Proposed resolution (October, 2009):
Change 9.6 [dcl.fct.def] paragraph 9 as follows:
A function definition of the form:
decl-specifier-seqopt attribute-specifieropt declarator= default ;
is called anexplicitly-defaulted definition.
Only specialmember functions may be explicitly defaulted, and the implementationshall define them as if they had implicit definitions (11.4.5 [class.ctor], 11.4.7 [class.dtor], 11.4.5.3 [class.copy.ctor]).A function that is explicitly defaulted shall
be a special member function,
have the same declared function type (except for possibly-differingref-qualifiers and except that in the case of a copy constructoror copy assignment operator, the parameter type may be“reference to non-constT,” whereT isthe name of the member function's class) as if it had been implicitlydeclared,
not have default arguments, and
not have anexception-specification.
[Note: This implies that parameter types, return type,and cv-qualifiers must match the hypothetical implicit declaration.—end note] An explicitly-defaulted function may be declaredconstexpr only if it would have been implicitly declared as constexpr.If it is explicitly defaulted on its first declaration,
it shall be public,
it shall not be explicit,
it shall not be virtual,
it is implicitly considered to have the sameexception-specification as if it had been implicitlydeclared (14.5 [except.spec]), and
in the case of a copy constructor or copy assignmentoperator, it shall have the same parameter type as if it had beenimplicitly declared.
[Note: Such a special member function may be trivial,and thus its accessibility and explicitness should match thehypothetical implicit definition; see below. —end note][Example:
struct S { S(int a = 0) = default; // ill-formed: default argument void operator=(const S&) = default; // ill-formed: non-matching return type ~S() throw() = default; // ill-formed: exception-specification private: S(S&); // OK: private copy constructor }; S::S(S&) = default; // OK: defines copy constructor—end example] Explicitly-defaulted functions andimplicitly-declared functions are collectively calleddefaultedfunctions, and the implementation shall provide implicit definitionsfor them (11.4.5 [class.ctor], 11.4.7 [class.dtor],11.4.5.3 [class.copy.ctor]), which might mean defining them asdeleted.A special member function that would be implicitlydefined as deleted may be explicitly defaulted only on its firstdeclaration, in which case it is defined as deleted. A special memberfunction isuser-provided if it is user-declared and notexplicitly defaulted on its first declaration. A user-providedexplicitly-defaulted function is defined at the point where it isexplicitly defaulted. [Note:...
[Editorial note: this change incorporates the overlapping portionof the resolution ofissue 667.]
Change 11.4.5 [class.ctor] paragraph 6 as follows:
This resolution also resolvesissue 905.See alsoissue 667.