@@ -601,15 +601,15 @@ The compiler no longer rewrites expressions using `operator==` if they involve a
601601
602602```cpp
603603struct U {
604- operator bool() const;
604+ operator bool() const;
605605};
606606
607607struct S {
608- U operator==(const S&) const;
608+ U operator==(const S&) const;
609609};
610610
611611bool neq(const S& lhs, const S& rhs) {
612- return lhs != rhs;
612+ return lhs != rhs;
613613}
614614```
615615
@@ -652,13 +652,13 @@ To avoid the error, define a body for the operator:
652652#include < compare>
653653
654654union S {
655- int a;
656- char b;
657- auto operator<=>(const S&) const { ... }
658- };
655+ int a;
656+ char b;
657+ auto operator<=>(const S&) const { ... }
658+ };
659659
660660bool lt (const S& lhs, const S& rhs) {
661- return lhs < rhs;
661+ return lhs < rhs;
662662}
663663```
664664
@@ -788,13 +788,13 @@ The code in this example no longer compiles:
788788#include < compare>
789789
790790struct S {
791- std::strong_equality operator<=>(const S&) const = default;
791+ std::strong_equality operator<=>(const S&) const = default;
792792};
793793
794794void f() {
795- nullptr<=>nullptr;
796- &f <=> &f;
797- &S::operator<=> <=> &S::operator<=>;
795+ nullptr<=>nullptr;
796+ &f <=> &f;
797+ &S::operator<=> <=> &S::operator<=>;
798798}
799799```
800800
@@ -810,19 +810,19 @@ error C7546: binary operator '<=>': unsupported operand types 'void (__cdecl *)(
810810error C7546: binary operator '<=>': unsupported operand types 'int (__thiscall S::* )(const S &) const' and 'int (__thiscall S::* )(const S &) const'
811811```
812812
813- To resolve the issue, update the ` operator<=> ` return types:
813+ To resolve the issue, update to prefer the built-in relational operators and replace the removed types:
814814
815815``` cpp
816816#include < compare>
817817
818818struct S {
819- std::strong_ordering operator<=>(const S&) const = default; // prefer 'std::strong_ordering'
819+ std::strong_ordering operator<=>(const S&) const = default; // prefer 'std::strong_ordering'
820820};
821821
822822void f() {
823- nullptr != nullptr; // use pre-existing builtin operator != or ==.
824- &f != &f;
825- &S::operator<=> != &S::operator<=>;
823+ nullptr != nullptr; // use pre-existing builtin operator != or ==.
824+ &f != &f;
825+ &S::operator<=> != &S::operator<=>;
826826}
827827```
828828
0 commit comments