Title
Unclear results if both member and friend operator<=> are declared
Status
c++20
Section
11.10.1 [class.compare.default]
Submitter
Daveed Vandevoorde

Created on 2019-05-20.00:00:00 last changed 67 months ago

Messages

Date: 2020-02-15.00:00:00

[Resolved by paper P2002R1, adopted at the February, 2020 meeting.]

According to 11.10.1 [class.compare.default] paragraph 2,

If the class definition does not explicitly declare an == operator function, but declares a defaulted three-way comparison operator function, an == operator function is declared implicitly with the same access as the three-way comparison operator function. The implicitly-declared == operator for a class X is an inline member and is defined as defaulted in the definition of X. If the three-way comparison operator function is declared as a non-static const member, the implicitly-declared == operator function is a member of the form

  bool X::operator==(const X&) const;

Otherwise, the implicitly-declared == operator function is of the form

  friend bool operator==(const X&, const X&);

Paragraph 1 of the section does not preclude declaring both a member and a friend operator<=>, and it is not clear how the operator== should be declared in that case.

History
Date User Action Args
2019-05-20 00:00:00admincreate