tmp/tmpu5v_jieh/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
### Equality operator <a id="class.eq">[[class.eq]]</a>
|
| 2 |
+
|
| 3 |
+
A defaulted equality operator function [[over.binary]] shall have a
|
| 4 |
+
declared return type `bool`.
|
| 5 |
+
|
| 6 |
+
A defaulted `==` operator function for a class `C` is defined as deleted
|
| 7 |
+
unless, for each `xᵢ` in the expanded list of subobjects for an object
|
| 8 |
+
`x` of type `C`, `xᵢ`` == ``xᵢ` is usable [[class.compare.default]].
|
| 9 |
+
|
| 10 |
+
The return value `V` of a defaulted `==` operator function with
|
| 11 |
+
parameters `x` and `y` is determined by comparing corresponding elements
|
| 12 |
+
`xᵢ` and `yᵢ` in the expanded lists of subobjects for `x` and `y` (in
|
| 13 |
+
increasing index order) until the first index i where `xᵢ`` == ``yᵢ`
|
| 14 |
+
yields a result value which, when contextually converted to `bool`,
|
| 15 |
+
yields `false`. If no such index exists, `V` is `true`. Otherwise, `V`
|
| 16 |
+
is `false`.
|
| 17 |
+
|
| 18 |
+
[*Example 1*:
|
| 19 |
+
|
| 20 |
+
``` cpp
|
| 21 |
+
struct D {
|
| 22 |
+
int i;
|
| 23 |
+
friend bool operator==(const D& x, const D& y) = default;
|
| 24 |
+
// OK, returns x.i == y.i
|
| 25 |
+
};
|
| 26 |
+
```
|
| 27 |
+
|
| 28 |
+
— *end example*]
|
| 29 |
+
|