Title
Defaulted special member functions
Status
c++23
Section
9.5.2 [dcl.fct.def.default]
Submitter
US

Created on 2022-11-03.00:00:00 last changed 9 months ago

Messages

Date: 2022-11-27.21:00:25
P2720R0 comment US 20-052

[Accepted as a DR at the November, 2022 meeting.]

The exposition in terms of F1 and F2 as well as T1 and T2 is confusing.

Possible resolution:

Change in 9.5.2 [dcl.fct.def.default] paragraph 2 as follows:

An explicitly defaulted special member function F1 with type T1 is allowed to differ from the corresponding special member function F2 with type T2 that would have been implicitly declared, as follows:
  • T1 F1 and T2 F2 may have differing ref-qualifier s;
  • if F2 has an implicit object parameter of type “reference to C”, F1 may be an explicit object member function whose explicit object parameter is of type “reference to C”, in which case T1 the type of F1 would differ from T2 the type of F2 in that T1 the type of F1 has an additional parameter;
  • T1 F1 and T2 F2 may have differing exception specifications; and
  • if F2 has a non-object parameter of type const C&, the corresponding non-object parameter of F1 may be of type C&.
If T1 the type of F1 differs from T2 the type of F2 in a way other than as allowed by the preceding rules, then:
  • if F1 is an assignment operator, and the return type of T1 F1 differs from the return type of T2 F2 or F1 's non-object parameter type is not a reference, the program is ill-formed;
  • otherwise, if F1 is explicitly defaulted on its first declaration, it is defined as deleted;
  • otherwise, the program is ill-formed.
History
Date User Action Args
2023-07-16 13:00:43adminsetstatus: open -> c++23
2023-07-16 13:00:43adminsetstatus: drwp -> open
2023-02-18 18:43:04adminsetstatus: dr -> drwp
2022-11-25 05:14:04adminsetstatus: nb -> dr
2022-11-08 07:26:56adminsetstatus: open -> nb
2022-11-08 07:26:56adminsetstatus: open -> open
2022-11-08 07:26:56adminsetstatus: open -> open
2022-11-08 07:26:56adminsetstatus: open -> open
2022-11-07 22:52:50adminsetstatus: nb -> open
2022-11-07 22:52:50adminsetstatus: nb -> nb
2022-11-07 22:52:50adminsetstatus: nb -> nb
2022-11-03 00:00:00admincreate