I'm dealing with 667 by reorganizing the clause 12 sections to say that an implicit declaration is implicitly defaulted, and then building everything else on the notion of defaulted functions.
I deal with 928 by just saying that if a function is defaulted and therefore deleted outside the class body, the program is ill-formed.
Only special member functions may be explicitly defaulted. Explicitly-defaulted functions and implicitly-declared functions are collectively called defaulted functions, and the implementation shall[class.ctor]/5:define them as if they hadprovide implicit definitions for them (12.1 [class.ctor], 12.4 [class.dtor], 12.8 [class.copy]), which might mean defining them as deleted.A special member function that would be implicitly defined as deleted shall not be explicitly defaulted.A special member function is user-provided if it is user-declared and not explicitly defaulted on its first declaration. A user-provided explicitly-defaulted function is defined at the point where it is explicitly defaulted; if such a function is implicitly defined as deleted, the program is ill-formed.
... If there is no user-declared constructor for class X, a constructor having no parameters is implicitly declared as defaulted (8.4). An implicitly-declared default constructor is an inline public member of its class.12.4 [class.dtor]/3:A default constructor is trivial if it is not user-provided (8.4) and if:
its class has no virtual functions (10.3) and no virtual base classes (10.1), andno non-static data member of its class has a brace-or-equal-initializer, andall the direct base classes of its class have trivial default constructors, andfor all the non-static data members of its class that are of class type (or array thereof), each such class has a trivial default constructor.A
n implicitly-declareddefaulted default constructor for class X is defined as deleted if:
- X is a union-like class that has a variant member with a non-trivial default constructor,
- any non-static data member is of reference type,
- any non-static data member of const-qualified type (or array thereof) does not have a user-provided default constructor, or
- any non-static data member or direct or virtual base class has class type M (or array thereof) and M has no default constructor, or if overload resolution (13.3) as applied to M's default constructor, results in an ambiguity or a function that is deleted or inaccessible from the implicitly-declared default constructor.
A default constructor is trivial if it is neither user-provided nor deleted and if:
- its class has no virtual functions (10.3) and no virtual base classes (10.1), and
- no non-static data member of its class has a brace-or-equal-initializer, and
- all the direct base classes of its class have trivial default constructors, and
- for all the non-static data members of its class that are of class type (or array thereof), each such class has a trivial default constructor.
Otherwise, the default constructor is non-trivial.
A
non-user-provideddefault constructorfor a classthat is defaulted and not defined as deleted is implicitly defined when it is used (3.2) to create an object of its class type (1.8), or when it is explicitly defaulted after its first declaration.If the implicitly-defined default constructor is explicitly defaulted but the corresponding implicit declaration would have been deleted, the program is ill-formed.The implicitly-definedor explicitly-defaulteddefault constructor performs the set of initializations of the class that would be performed by a user-written default constructor for that class with no ctor-initializer (12.6.2) and an empty compound-statement. If that user-written default constructor would be ill-formed, the program is ill-formed. If that user-written default constructor would satisfy the requirements of a constexpr constructor (7.1.5), the implicitly-defined default constructor is constexpr. Before thenon-user-provideddefaulted default constructor for a class is implicitly defined, all the non-user-provided default constructors for its base classes and its non-static data members shall have been implicitly defined. [ Note: an implicitly-declared default constructor has an exception-specification (15.4). An explicitly-defaulted definition has no implicit exception-specification. --end note ]
If a class has no user-declared destructor, a destructor is12.8 [class.copy]:declaredimplicitly declared as defaulted (8.4). An implicitly-declared destructor is an inline public member of its class.If the class is a union-like class that has a variant member with a non-trivial destructor, an implicitly-declared destructor is defined as deleted (8.4).A destructor is trivial if it is not user-provided and if:A
the destructor is not virtual,all of the direct base classes of its class have trivial destructors, andfor all of the non-static data members of its class that are of class type (or array thereof), each such class has a trivial destructor.n implicitly-declareddefaulted destructor for a class X is defined as deleted if:A destructor is trivial if it is neither user-provided nor deleted and if:
- X is a union-like class that has a variant member with a non-trivial destructor,
- any of the non-static data members has class type M (or array thereof) and M has an deleted destructor or a destructor that is inaccessible from the implicitly-declared destructor, or
- any direct or virtual base class has a deleted destructor or a destructor that is inaccessible from the implicitly-declared destructor.
Otherwise, the destructor is non-trivial.
- the destructor is not virtual,
- all of the direct base classes of its class have trivial destructors, and
- for all of the non-static data members of its class that are of class type (or array thereof), each such class has a trivial destructor.
A
non-user-provideddestructor that is defaulted and not defined as deleted is implicitly defined when it is used to destroy an object of its class type (3.7), or when it is explicitly defaulted after its first declaration.A program is ill-formed if the class for which a destructor is implicitly defined or explicitly defaulted has:
a non-static data member of class type (or array thereof) with an inaccessible destructor, ora base class with an inaccessible destructor.A program is ill-formed if the implicitly-defined destructor is explicitly defaulted but the corresponding implicit declaration would have been deleted.Before thenon-user-provideddefaulted destructor for a class is implicitly defined, all the non-user-definedprovided destructors for its base classes and its non-static data members shall have been implicitly defined. [ Note: an implicitly-declared destructor has an exception-specification (15.4). An explictly defaulted definition has no implicit exception-specification. -- end note ]
If the class definition does not explicitly declare a copy constructor, one isdeclaredimplicitly declared as defaulted (8.4).....
An implicitly-declared copy constructor is an inline public member of its class. An implicitly-declareddefaulted copy constructor for a class X is defined as deleted if X has:A copy constructor for class X is trivial if it is
- a variant member with a non-trivial copy constructor and X is a union-like class,
- a non-static data member of class type M (or array thereof) that cannot be copied because overload resolution (13.3), as applied to M's copy constructor, results in an ambiguity or a function that is deleted or inaccessible from the implicitly-declared copy constructor, or
- a direct or virtual base class B that cannot be copied because overload resolution (13.3), as applied to B's copy constructor, results in an ambiguity or a function that is deleted or inaccessible from the implicitly-declared copy constructor.
notneither user-provided nor deleted(8.4)and ifotherwise the copy constructor is non-trivial.
- class X has no virtual functions (10.3) and no virtual base classes (10.1), and
- the constructor selected to copy each direct base class subobject is trivial, and
- for each non-static data memberof X that is of class type (or array thereof), the constructor selected to copy that member is trivial;
A
non-user-providedcopy constructor that is defaulted and not defined as deleted is implicitly defined if it is used to initialize an object of its class type from a copy of an object of its class type or of a class type derived from its class type [ Footnote .... ], or when it is explicitly defaulted after its first declaration. [ Note: the copy constructor is implicitly defined even if the implementation elided its use (12.2). -- end note ]A program is ill-formed if the implicitly-defined copy constructor is explicitly defaulted but the corresponding implicit declaration would have been deleted.Before the
non-user-provideddefaulted copy constructor for a class is implicitly defined, all non-user-provided copy constructors for its direct and virtual base classes and its non-static data members shall have been implicitly defined. [ Note: an implicitly-declared copy constructor has an exception-specification (15.4). An explicitly- defaulted definition has no implicit exception-specification. -- end note ]The implicitly-defined
or explicitly-defaultedcopy constructor for a non-union class X performs a memberwise copy of its subobjects. [ Note: brace-or-equal-initializers of non-static data members are ignored. See also the example in 12.6.2. -- end note ] The order of copying is the same as the order of initialization of bases and members in a user-defined constructor (see 12.6.2). Each subobject is copied in the manner appropriate to its type:Virtual base class subobjects shall be copied only once by the implicitly-defined copy constructor (see 12.6.2).
- if the subobject is of class type, the copy constructor for the class is used;
- if the subobject is an array, each element is copied, in the manner appropriate to the element type;
- if the subobject is of scalar type, the built-in assignment operator is used.
The implicitly-defined
or explicitly-defaultedcopy constructor for a union X copies the object representation (3.9) of X.....
If the class definition does not explicitly declare a copy assignment operator, one is
declaredimplicitly declared as defaulted (8.4).....
An implicitly-declared copy assignment operator is an inline public member of its class. A
n implicitly-declareddefaulted copy assignment operator for class X is defined as deleted if X has:Because a copy assignment operator is implicitly declared for a class if not declared by the user, a base class copy assignment operator is always hidden by the copy assignment operator of a derived class (13.5.3). A using-declaration (7.3.3) that brings in from a base class an assignment operator with a parameter type that could be that of a copy-assignment operator for the derived class is not considered an explicit declaration of a copy-assignment operator and does not suppress the implicit declaration of the derived class copy- assignment operator; the operator introduced by the using-declaration is hidden by the implicitly-declared copy-assignment operator in the derived class.
- a variant member with a non-trivial copy assignment operator and X is a union-like class,
- a non-static data member of const non-class type (or array thereof), or
- a non-static data member of reference type, or
- a non-static data member of class type M (or array thereof) that cannot be copied because overload resolution (13.3), as applied to M's copy assignment operator, results in an ambiguity or a function that is deleted or inaccessible from the implicitly-declared copy assignment operator, or
- a direct or virtual base class B that cannot be copied because overload resolution (13.3), as applied to B’s copy assignment operator, results in an ambiguity or a function that is deleted or inaccessible from the implicitly-declared copy assignment operator.
A copy assignment operator for class X is trivial if it is
notneither user-provided nor deleted and ifotherwise the copy assignment operator is non-trivial.
- class X has no virtual functions (10.3) and no virtual base classes (10.1), and
- the assignment operator selected to copy each direct base class subobject is trivial, and
- for each non-static data memberof X that is of class type (or array thereof), the assignment operator selected to copy that member is trivial;
A
non-user-providedcopy assignment operator that is defaulted and not defined as deleted is implicitly defined when an object of its class type is assigned a value of its class type or a value of a class type derived from its class type, or when it is explicitly defaulted after its first declaration.A program is ill-formed if the implicitly-defined copy assignment operator is explicitly defaulted but the corresponding implicit declaration would have been deleted.Before the
non-user-provideddefaulted copy assignment operator for a class is implicitly defined, all non-user-provided copy assignment operators for its direct base classes and its non-static data members shall have been implicitly defined. [ Note: an implicitly-declared copy assignment operator has an exception-specification (15.4). An explicitly-defaulted definition has no implicit exception-specification. -- end note ]The implicitly-defined
or explicitly-defaultedcopy assignment operator for a non-union class X performs memberwise assignment of its subobjects. The direct base classes of X are assigned first, in the order of their declaration in the base-specifier-list, and then the immediate non-static data members of X are assigned, in the order in which they were declared in the class definition. Each subobject is assigned in the manner appropriate to its type:It is unspecified whether subobjects representing virtual base classes are assigned more than once by the implicitly-defined
- if the subobject is of class type, the copy assignment operator for the class is used (as if by explicit qualification; that is, ignoring any possible virtual overriding functions in more derived classes);
- if the subobject is an array, each element is assigned, in the manner appropriate to the element type;
- if the subobject is of scalar type, the built-in assignment operator is used.
or explicitly-defaultedcopy assignment operator. [ Example:struct V { }; struct A : virtual V { }; struct B : virtual V { }; struct C : B, A { };It is unspecified whether the virtual base class subobject V is assigned twice by the implicitly-defined copy assignment operator for C. -- end example ]The implicitly-defined
or explicitly-defaultedcopy assignment operator for a uniontcodeX copies the object representation (3.9) of X.