This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 110c. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2023-02-07


2414. Unclear results if both member and friend operator<=> are declared

Section: 11.10.1  [class.compare.default]     Status: C++20     Submitter: Daveed Vandevoorde     Date: 2019-05-20

[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.