Created on 2011-08-16.00:00:00 last changed 11 months ago
Proposed resolution (approved by CWG 2023-02-07):
Change in 11.4.5.2 [class.default.ctor] paragraph 2 as follows:
A defaulted default constructor for class X is defined as deleted if:
X is a union that has a variant member with a non-trivial default constructor and no variant member of X has a default member initializer,X is a non-union class that has a variant member M with a non-trivial default constructor and no variant member of the anonymous union containing M has a default member initializer,- any non-static data member with no default member initializer (11.4 [class.mem]) is of reference type,
- any non-variant non-static data member of const-qualified type (or possibly multi-dimensional array thereof) with no brace-or-equal-initializer is not const-default-constructible (9.4 [dcl.init]),
- X is a union and all of its variant members are of const-qualified type (or possibly multi-dimensional array thereof),
- X is a non-union class and all members of any anonymous union member are of const-qualified type (or possibly multi-dimensional array thereof),
- any potentially constructed subobject, except for a non-static data member with a brace-or-equal-initializer or a variant member of a union where another non-static data member has a brace-or-equal-initializer, has class type M (or possibly multi-dimensional array thereof) and
either M has no default constructor oroverload resolution (12.2 [over.match]) as applied to find M's corresponding constructorresults in an ambiguity or in a function that is deleted or inaccessible from the defaulted default constructoreither does not result in a usable candidate (12.2.1 [over.match.general]) or, in the case of a variant member, selects a non-trivial function, or- any potentially constructed subobject has
a type withclass type M (or possibly multi-dimensional array thereof) and M has a destructor that is deleted or inaccessible from the defaulted default constructor.
Change in 11.4.5.3 [class.copy.ctor] paragraph 10 as follows:
... A defaulted copy/move constructor for a class X is defined as deleted (9.5.3 [dcl.fct.def.delete]) if X has:
- a potentially constructed subobject of type M (or possibly multi-dimensional array thereof)
that cannot be copied/moved becausefor which overload resolution (12.2 [over.match]), as applied to find M's corresponding constructor,results in an ambiguity or a function that is deleted or inaccessible from the defaulted constructoreither does not result in a usable candidate (12.2.1 [over.match.general]) or, in the case of a variant member, selects a non-trivial function,a variant member whose corresponding constructor as selected by overload resolution is non-trivial,- any potentially constructed subobject of
a type withclass type M (or possibly multi-dimensional array thereof) where M has a destructor that is deleted or inaccessible from the defaulted constructor, or,- for the copy constructor, a non-static data member of rvalue reference type.
Change in 11.4.6 [class.copy.assign] paragraph 7 as follows:
A defaulted copy/move assignment operator for class X is defined as deleted if X has:
a variant member with a non-trivial corresponding assignment operator and X is a union-like class, or- a non-static data member of const non-class type (or possibly multi-dimensional array thereof), or
- a non-static data member of reference type, or
- a direct non-static data member of class type M (or possibly multi-dimensional array thereof) or a direct base class M that cannot be copied/moved because overload resolution (12.2 [over.match]), as applied to find M's corresponding assignment operator,
results in an ambiguity or a function that is deleted or inaccessible from the defaulted assignment operatoreither does not result in a usable candidate (12.2.1 [over.match.general]) or, in the case of a variant member, selects a non-trivial function.
Change in 11.4.7 [class.dtor] paragraph 7 as follows:
A defaulted destructor for a class X is defined as deleted if:
X is a union-like class that has a variant member with a non-trivial destructor,- any potentially constructed subobject has class type M (or possibly multi-dimensional array thereof) and M has a
deleteddestructor that is deleted ora destructor thatis inaccessible from the defaulted destructor or, in the case of a variant member, is non-trivial,- or, for a virtual destructor, lookup of the non-array deallocation function results in an ambiguity or in a function that is deleted or inaccessible from the defaulted destructor.
[Accepted as a DR at the June, 2023 meeting.]
The specification of when a defaulted special member function is to be defined as deleted sometimes overlooks variant and array members.
History | |||
---|---|---|---|
Date | User | Action | Args |
2023-12-19 10:15:28 | admin | set | status: dr -> drwp |
2023-07-16 13:00:43 | admin | set | status: ready -> dr |
2023-06-13 15:29:28 | admin | set | status: tentatively ready -> ready |
2023-02-08 04:43:09 | admin | set | messages: + msg7174 |
2023-02-08 04:43:09 | admin | set | status: drafting -> tentatively ready |
2011-08-16 00:00:00 | admin | create |