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 |
+
|