The program is well-formed as per dcl.fct.def.default#2.6 which is applicable when none of the first four bullets in dcl.fct.def.default are satisfied. So we move onto the latter part which says if F1
is explicitly defaulted on its first declaration, it will be defined as deleted. Note that this change was made by P0641R2 which made C(const C&&) = default;
deleted instead of ill-formed. So the program is well-formed.
Note also that CWG2476 allowed constructors to have a type as explained in Can constructors have type.
Now, from dcl.fct.def.default:
An explicitly defaulted special member function F1 is allowed to differ from the corresponding special member function F2 that would have been implicitly declared, as follows:
- F1 and F2 may have differing ref-qualifiers;
- 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 (possibly different) type “reference to C”, in which case the type of F1 would differ from the type of F2 in that the type of F1 has an additional parameter;
- F1 and 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&.
As we can see none of the above four bullet points apply. So we move onto the next part that says:
If the type of F1 differs from 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 F1 differs from the return type of 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;
As you can see the move ctor C::C(const C&&)
should be defined as deleted
.
C::C(const C&&)
is also a move ctor. – Guffawsingle-parameter-list
- a parameter list of only one parameter, which is of type T&&, const T&&". GCC, clang and msvc are wrong in giving a diagnostic here. – Guffaw