From Jason Turner

[diff.cpp17.over]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp9z3dtx7q/{from.md → to.md} +27 -0
tmp/tmp9z3dtx7q/{from.md → to.md} RENAMED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### [[over]]: overloading <a id="diff.cpp17.over">[[diff.cpp17.over]]</a>
2
+
3
+ **Change:** Equality and inequality expressions can now find reversed
4
+ and rewritten candidates. **Rationale:** Improve consistency of equality
5
+ with three-way comparison and make it easier to write the full
6
+ complement of equality operations. **Effect on original feature:**
7
+ Equality and inequality expressions between two objects of different
8
+ types, where one is convertible to the other, could invoke a different
9
+ operator. Equality and inequality expressions between two objects of the
10
+ same type could become ambiguous.
11
+
12
+ ``` cpp
13
+ struct A {
14
+ operator int() const;
15
+ };
16
+
17
+ bool operator==(A, int); // #1
18
+ // #2 is built-in candidate: bool operator==(int, int);
19
+ // #3 is built-in candidate: bool operator!=(int, int);
20
+
21
+ int check(A x, A y) {
22
+ return (x == y) + // ill-formed; previously well-formed
23
+ (10 == x) + // calls #1, previously selected #2
24
+ (10 != x); // calls #1, previously selected #3
25
+ }
26
+ ```
27
+