tmp/tmpcvl6jfq5/{from.md → to.md}
RENAMED
|
@@ -1,51 +1,58 @@
|
|
| 1 |
-
## Relational operators <a id="expr.rel">[[expr.rel]]</a>
|
| 2 |
|
| 3 |
The relational operators group left-to-right.
|
| 4 |
|
| 5 |
[*Example 1*: `a<b<c` means `(a<b)<c` and *not*
|
| 6 |
`(a<b)&&(b<c)`. — *end example*]
|
| 7 |
|
| 8 |
``` bnf
|
| 9 |
relational-expression:
|
| 10 |
-
|
| 11 |
-
relational-expression '<'
|
| 12 |
-
relational-expression '>'
|
| 13 |
-
relational-expression '<='
|
| 14 |
-
relational-expression '>='
|
| 15 |
```
|
| 16 |
|
| 17 |
-
The
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
|
| 22 |
-
The
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
type (Clause [[expr]]). After conversions, the operands shall have the
|
| 27 |
-
same type.
|
| 28 |
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
- If two pointers point to different elements of the same array, or to
|
| 32 |
subobjects thereof, the pointer to the element with the higher
|
| 33 |
-
subscript
|
| 34 |
- If two pointers point to different non-static data members of the same
|
| 35 |
object, or to subobjects of such members, recursively, the pointer to
|
| 36 |
-
the later declared member
|
| 37 |
-
have the same access control
|
| 38 |
-
their class is not a union.
|
| 39 |
-
- Otherwise, neither pointer
|
|
|
|
| 40 |
|
| 41 |
-
If two operands `p` and `q` compare equal
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
`
|
| 45 |
-
|
| 46 |
-
|
| 47 |
|
| 48 |
If both operands (after conversions) are of arithmetic or enumeration
|
| 49 |
type, each of the operators shall yield `true` if the specified
|
| 50 |
relationship is true and `false` if it is false.
|
| 51 |
|
|
|
|
| 1 |
+
### Relational operators <a id="expr.rel">[[expr.rel]]</a>
|
| 2 |
|
| 3 |
The relational operators group left-to-right.
|
| 4 |
|
| 5 |
[*Example 1*: `a<b<c` means `(a<b)<c` and *not*
|
| 6 |
`(a<b)&&(b<c)`. — *end example*]
|
| 7 |
|
| 8 |
``` bnf
|
| 9 |
relational-expression:
|
| 10 |
+
compare-expression
|
| 11 |
+
relational-expression '<' compare-expression
|
| 12 |
+
relational-expression '>' compare-expression
|
| 13 |
+
relational-expression '<=' compare-expression
|
| 14 |
+
relational-expression '>=' compare-expression
|
| 15 |
```
|
| 16 |
|
| 17 |
+
The lvalue-to-rvalue [[conv.lval]], array-to-pointer [[conv.array]], and
|
| 18 |
+
function-to-pointer [[conv.func]] standard conversions are performed on
|
| 19 |
+
the operands. The comparison is deprecated if both operands were of
|
| 20 |
+
array type prior to these conversions [[depr.array.comp]].
|
| 21 |
|
| 22 |
+
The converted operands shall have arithmetic, enumeration, or pointer
|
| 23 |
+
type. The operators `<` (less than), `>` (greater than), `<=` (less than
|
| 24 |
+
or equal to), and `>=` (greater than or equal to) all yield `false` or
|
| 25 |
+
`true`. The type of the result is `bool`.
|
|
|
|
|
|
|
| 26 |
|
| 27 |
+
The usual arithmetic conversions [[expr.arith.conv]] are performed on
|
| 28 |
+
operands of arithmetic or enumeration type. If both operands are
|
| 29 |
+
pointers, pointer conversions [[conv.ptr]] and qualification conversions
|
| 30 |
+
[[conv.qual]] are performed to bring them to their composite pointer
|
| 31 |
+
type [[expr.type]]. After conversions, the operands shall have the same
|
| 32 |
+
type.
|
| 33 |
+
|
| 34 |
+
The result of comparing unequal pointers to objects [^30] is defined in
|
| 35 |
+
terms of a partial order consistent with the following rules:
|
| 36 |
|
| 37 |
- If two pointers point to different elements of the same array, or to
|
| 38 |
subobjects thereof, the pointer to the element with the higher
|
| 39 |
+
subscript is required to compare greater.
|
| 40 |
- If two pointers point to different non-static data members of the same
|
| 41 |
object, or to subobjects of such members, recursively, the pointer to
|
| 42 |
+
the later declared member is required to compare greater provided the
|
| 43 |
+
two members have the same access control [[class.access]], neither
|
| 44 |
+
member is a subobject of zero size, and their class is not a union.
|
| 45 |
+
- Otherwise, neither pointer is required to compare greater than the
|
| 46 |
+
other.
|
| 47 |
|
| 48 |
+
If two operands `p` and `q` compare equal [[expr.eq]], `p<=q` and `p>=q`
|
| 49 |
+
both yield `true` and `p<q` and `p>q` both yield `false`. Otherwise, if
|
| 50 |
+
a pointer `p` compares greater than a pointer `q`, `p>=q`, `p>q`,
|
| 51 |
+
`q<=p`, and `q<p` all yield `true` and `p<=q`, `p<q`, `q>=p`, and `q>p`
|
| 52 |
+
all yield `false`. Otherwise, the result of each of the operators is
|
| 53 |
+
unspecified.
|
| 54 |
|
| 55 |
If both operands (after conversions) are of arithmetic or enumeration
|
| 56 |
type, each of the operators shall yield `true` if the specified
|
| 57 |
relationship is true and `false` if it is false.
|
| 58 |
|