From Jason Turner

[diff.cpp17.over]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpgsypi94v/{from.md → to.md} +10 -2
tmp/tmpgsypi94v/{from.md → to.md} RENAMED
@@ -6,11 +6,13 @@ with three-way comparison and make it easier to write the full
6
  complement of equality operations. **Effect on original feature:** For
7
  certain pairs of types where one is convertible to the other, equality
8
  or inequality expressions between an object of one type and an object of
9
  the other type invoke a different operator. Also, for certain types,
10
  equality or inequality expressions between two objects of that type
11
- become ambiguous. For example:
 
 
12
 
13
  ``` cpp
14
  struct A {
15
  operator int() const;
16
  };
@@ -24,15 +26,19 @@ int check(A x, A y) {
24
  (10 == x) + // calls #1, previously selected #2
25
  (10 != x); // calls #1, previously selected #3
26
  }
27
  ```
28
 
 
 
29
  **Change:** Overload resolution may change for equality operators
30
  [[expr.eq]]. **Rationale:** Support calling `operator==` with reversed
31
  order of arguments. **Effect on original feature:** Valid C++17 code
32
  that uses equality operators with conversion functions may be ill-formed
33
- or have different semantics in this revision of C++. For example:
 
 
34
 
35
  ``` cpp
36
  struct A {
37
  operator int() const { return 10; }
38
  };
@@ -46,5 +52,7 @@ struct B {
46
  };
47
  B b1;
48
  bool eq = (b1 == b1); // ambiguous; previously well-formed
49
  ```
50
 
 
 
 
6
  complement of equality operations. **Effect on original feature:** For
7
  certain pairs of types where one is convertible to the other, equality
8
  or inequality expressions between an object of one type and an object of
9
  the other type invoke a different operator. Also, for certain types,
10
  equality or inequality expressions between two objects of that type
11
+ become ambiguous.
12
+
13
+ [*Example 1*:
14
 
15
  ``` cpp
16
  struct A {
17
  operator int() const;
18
  };
 
26
  (10 == x) + // calls #1, previously selected #2
27
  (10 != x); // calls #1, previously selected #3
28
  }
29
  ```
30
 
31
+ — *end example*]
32
+
33
  **Change:** Overload resolution may change for equality operators
34
  [[expr.eq]]. **Rationale:** Support calling `operator==` with reversed
35
  order of arguments. **Effect on original feature:** Valid C++17 code
36
  that uses equality operators with conversion functions may be ill-formed
37
+ or have different semantics in this revision of C++.
38
+
39
+ [*Example 2*:
40
 
41
  ``` cpp
42
  struct A {
43
  operator int() const { return 10; }
44
  };
 
52
  };
53
  B b1;
54
  bool eq = (b1 == b1); // ambiguous; previously well-formed
55
  ```
56
 
57
+ — *end example*]
58
+