[diff.cpp17.over]

# Annex C (informative) Compatibility [[diff]](./#diff)

## C.3 C++ and ISO C++ 2017 [[diff.cpp17]](diff.cpp17#over)

### C.3.7 [[over]](over "12 Overloading"): overloading [diff.cpp17.over]

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1216)

**Affected subclause:** [[over.match.oper]](over.match.oper)  


**Change:** Equality and inequality expressions can now find
reversed and rewritten candidates[.](#1.sentence-1)

  


**Rationale:** Improve consistency of equality with three-way comparison
and make it easier to write the full complement of equality operations[.](#1.sentence-2)

  


**Effect on original feature:** For certain pairs of types where one is convertible to the other,
equality or inequality expressions between an object of one type
and an object of the other type invoke a different operator[.](#1.sentence-3)

Also, for certain types, equality or inequality expressions
between two objects of that type become ambiguous[.](#1.sentence-4)

[*Example [1](#example-1)*: struct A {operator int() const;};

bool operator==(A, int); // #1// #2 is built-in candidate: bool operator==(int, int);// #3 is built-in candidate: bool operator!=(int, int);int check(A x, A y) {return (x == y) + // ill-formed; previously well-formed(10 == x) + // calls #1, previously selected #2(10 != x); // calls #1, previously selected #3} â *end example*]

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1247)

**Affected subclause:** [[over.match.oper]](over.match.oper)  


**Change:** Overload resolution may change for equality operators ([[expr.eq]](expr.eq "7.6.10 Equality operators"))[.](#2.sentence-1)

  


**Rationale:** Support calling operator== with reversed order of arguments[.](#2.sentence-2)

  


**Effect on original feature:** Valid C++ 2017 code that uses equality operators with conversion functions
may be ill-formed or have different semantics in this revision of C++[.](#2.sentence-3)

[*Example [2](#example-2)*: struct A {operator int() const { return 10; }};

bool operator==(A, int); // #1// #2 is built-in candidate: bool operator==(int, int);bool b = 10 == A(); // calls #1 with reversed order of arguments; previously selected #2struct B {bool operator==(const B&); // member function with no cv-qualifier};
B b1;bool eq = (b1 == b1); // ambiguous; previously well-formed â *end example*]
