tmp/tmpv12o6wa_/{from.md → to.md}
RENAMED
|
@@ -1,28 +1,29 @@
|
|
| 1 |
### Concept-constrained comparisons <a id="range.cmp">[[range.cmp]]</a>
|
| 2 |
|
| 3 |
-
In this subclause, `BUILTIN-PTR-CMP(T, op, U)` for types `T` and `U` and
|
| 4 |
-
where op is an equality [[expr.eq]] or relational operator [[expr.rel]]
|
| 5 |
-
is a boolean constant expression. `BUILTIN-PTR-CMP(T, op, U)` is `true`
|
| 6 |
-
if and only if op in the expression `declval<T>() op declval<U>()`
|
| 7 |
-
resolves to a built-in operator comparing pointers.
|
| 8 |
-
|
| 9 |
``` cpp
|
| 10 |
struct ranges::equal_to {
|
| 11 |
template<class T, class U>
|
| 12 |
-
requires equality_comparable_with<T, U> || BUILTIN-PTR-CMP(T, ==, U)
|
| 13 |
constexpr bool operator()(T&& t, U&& u) const;
|
| 14 |
|
| 15 |
using is_transparent = unspecified;
|
| 16 |
};
|
| 17 |
```
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
*Preconditions:* If the expression
|
| 20 |
`std::forward<T>(t) == std::forward<U>(u)` results in a call to a
|
| 21 |
built-in operator `==` comparing pointers of type `P`, the conversion
|
| 22 |
sequences from both `T` and `U` to `P` are
|
| 23 |
-
equality-preserving [[concepts.equality]]
|
|
|
|
| 24 |
|
| 25 |
*Effects:*
|
| 26 |
|
| 27 |
- If the expression `std::forward<T>(t) == std::forward<U>(u)` results
|
| 28 |
in a call to a built-in operator `==` comparing pointers: returns
|
|
@@ -33,56 +34,75 @@ equality-preserving [[concepts.equality]].
|
|
| 33 |
`return std::forward<T>(t) == std::forward<U>(u);`
|
| 34 |
|
| 35 |
``` cpp
|
| 36 |
struct ranges::not_equal_to {
|
| 37 |
template<class T, class U>
|
| 38 |
-
requires equality_comparable_with<T, U> || BUILTIN-PTR-CMP(T, ==, U)
|
| 39 |
constexpr bool operator()(T&& t, U&& u) const;
|
| 40 |
|
| 41 |
using is_transparent = unspecified;
|
| 42 |
};
|
| 43 |
```
|
| 44 |
|
| 45 |
-
`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
``` cpp
|
| 48 |
return !ranges::equal_to{}(std::forward<T>(t), std::forward<U>(u));
|
| 49 |
```
|
| 50 |
|
| 51 |
``` cpp
|
| 52 |
struct ranges::greater {
|
| 53 |
template<class T, class U>
|
| 54 |
-
requires totally_ordered_with<T, U> || BUILTIN-PTR-CMP(U, <, T)
|
| 55 |
constexpr bool operator()(T&& t, U&& u) const;
|
| 56 |
|
| 57 |
using is_transparent = unspecified;
|
| 58 |
};
|
| 59 |
```
|
| 60 |
|
| 61 |
-
`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
|
| 63 |
``` cpp
|
| 64 |
return ranges::less{}(std::forward<U>(u), std::forward<T>(t));
|
| 65 |
```
|
| 66 |
|
| 67 |
``` cpp
|
| 68 |
struct ranges::less {
|
| 69 |
template<class T, class U>
|
| 70 |
-
requires totally_ordered_with<T, U> || BUILTIN-PTR-CMP(T, <, U)
|
| 71 |
constexpr bool operator()(T&& t, U&& u) const;
|
| 72 |
|
| 73 |
using is_transparent = unspecified;
|
| 74 |
};
|
| 75 |
```
|
| 76 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
*Preconditions:* If the expression
|
| 78 |
`std::forward<T>(t) < std::forward<U>(u)` results in a call to a
|
| 79 |
built-in operator `<` comparing pointers of type `P`, the conversion
|
| 80 |
sequences from both `T` and `U` to `P` are
|
| 81 |
-
equality-preserving [[concepts.equality]]
|
| 82 |
-
`
|
| 83 |
-
|
|
|
|
| 84 |
`ranges::equal_to{}(ET, EU)` is `true`.
|
| 85 |
|
| 86 |
*Effects:*
|
| 87 |
|
| 88 |
- If the expression `std::forward<T>(t) < std::forward<U>(u)` results in
|
|
@@ -94,34 +114,46 @@ exactly one of `ranges::less{}(ET, EU)`, `ranges::less{}(EU, ET)`, or
|
|
| 94 |
`return std::forward<T>(t) < std::forward<U>(u);`
|
| 95 |
|
| 96 |
``` cpp
|
| 97 |
struct ranges::greater_equal {
|
| 98 |
template<class T, class U>
|
| 99 |
-
requires totally_ordered_with<T, U> || BUILTIN-PTR-CMP(T, <, U)
|
| 100 |
constexpr bool operator()(T&& t, U&& u) const;
|
| 101 |
|
| 102 |
using is_transparent = unspecified;
|
| 103 |
};
|
| 104 |
```
|
| 105 |
|
| 106 |
-
`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
|
| 108 |
``` cpp
|
| 109 |
return !ranges::less{}(std::forward<T>(t), std::forward<U>(u));
|
| 110 |
```
|
| 111 |
|
| 112 |
``` cpp
|
| 113 |
struct ranges::less_equal {
|
| 114 |
template<class T, class U>
|
| 115 |
-
requires totally_ordered_with<T, U> || BUILTIN-PTR-CMP(U, <, T)
|
| 116 |
constexpr bool operator()(T&& t, U&& u) const;
|
| 117 |
|
| 118 |
using is_transparent = unspecified;
|
| 119 |
};
|
| 120 |
```
|
| 121 |
|
| 122 |
-
`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
|
| 124 |
``` cpp
|
| 125 |
return !ranges::less{}(std::forward<U>(u), std::forward<T>(t));
|
| 126 |
```
|
| 127 |
|
|
|
|
| 1 |
### Concept-constrained comparisons <a id="range.cmp">[[range.cmp]]</a>
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
``` cpp
|
| 4 |
struct ranges::equal_to {
|
| 5 |
template<class T, class U>
|
|
|
|
| 6 |
constexpr bool operator()(T&& t, U&& u) const;
|
| 7 |
|
| 8 |
using is_transparent = unspecified;
|
| 9 |
};
|
| 10 |
```
|
| 11 |
|
| 12 |
+
``` cpp
|
| 13 |
+
template<class T, class U>
|
| 14 |
+
constexpr bool operator()(T&& t, U&& u) const;
|
| 15 |
+
```
|
| 16 |
+
|
| 17 |
+
*Constraints:* `T` and `U` satisfy `equality_comparable_with`.
|
| 18 |
+
|
| 19 |
*Preconditions:* If the expression
|
| 20 |
`std::forward<T>(t) == std::forward<U>(u)` results in a call to a
|
| 21 |
built-in operator `==` comparing pointers of type `P`, the conversion
|
| 22 |
sequences from both `T` and `U` to `P` are
|
| 23 |
+
equality-preserving [[concepts.equality]]; otherwise, `T` and `U` model
|
| 24 |
+
`equality_comparable_with`.
|
| 25 |
|
| 26 |
*Effects:*
|
| 27 |
|
| 28 |
- If the expression `std::forward<T>(t) == std::forward<U>(u)` results
|
| 29 |
in a call to a built-in operator `==` comparing pointers: returns
|
|
|
|
| 34 |
`return std::forward<T>(t) == std::forward<U>(u);`
|
| 35 |
|
| 36 |
``` cpp
|
| 37 |
struct ranges::not_equal_to {
|
| 38 |
template<class T, class U>
|
|
|
|
| 39 |
constexpr bool operator()(T&& t, U&& u) const;
|
| 40 |
|
| 41 |
using is_transparent = unspecified;
|
| 42 |
};
|
| 43 |
```
|
| 44 |
|
| 45 |
+
``` cpp
|
| 46 |
+
template<class T, class U>
|
| 47 |
+
constexpr bool operator()(T&& t, U&& u) const;
|
| 48 |
+
```
|
| 49 |
+
|
| 50 |
+
*Constraints:* `T` and `U` satisfy `equality_comparable_with`.
|
| 51 |
+
|
| 52 |
+
*Effects:* Equivalent to:
|
| 53 |
|
| 54 |
``` cpp
|
| 55 |
return !ranges::equal_to{}(std::forward<T>(t), std::forward<U>(u));
|
| 56 |
```
|
| 57 |
|
| 58 |
``` cpp
|
| 59 |
struct ranges::greater {
|
| 60 |
template<class T, class U>
|
|
|
|
| 61 |
constexpr bool operator()(T&& t, U&& u) const;
|
| 62 |
|
| 63 |
using is_transparent = unspecified;
|
| 64 |
};
|
| 65 |
```
|
| 66 |
|
| 67 |
+
``` cpp
|
| 68 |
+
template<class T, class U>
|
| 69 |
+
constexpr bool operator()(T&& t, U&& u) const;
|
| 70 |
+
```
|
| 71 |
+
|
| 72 |
+
*Constraints:* `T` and `U` satisfy `totally_ordered_with`.
|
| 73 |
+
|
| 74 |
+
*Effects:* Equivalent to:
|
| 75 |
|
| 76 |
``` cpp
|
| 77 |
return ranges::less{}(std::forward<U>(u), std::forward<T>(t));
|
| 78 |
```
|
| 79 |
|
| 80 |
``` cpp
|
| 81 |
struct ranges::less {
|
| 82 |
template<class T, class U>
|
|
|
|
| 83 |
constexpr bool operator()(T&& t, U&& u) const;
|
| 84 |
|
| 85 |
using is_transparent = unspecified;
|
| 86 |
};
|
| 87 |
```
|
| 88 |
|
| 89 |
+
``` cpp
|
| 90 |
+
template<class T, class U>
|
| 91 |
+
constexpr bool operator()(T&& t, U&& u) const;
|
| 92 |
+
```
|
| 93 |
+
|
| 94 |
+
*Constraints:* `T` and `U` satisfy `totally_ordered_with`.
|
| 95 |
+
|
| 96 |
*Preconditions:* If the expression
|
| 97 |
`std::forward<T>(t) < std::forward<U>(u)` results in a call to a
|
| 98 |
built-in operator `<` comparing pointers of type `P`, the conversion
|
| 99 |
sequences from both `T` and `U` to `P` are
|
| 100 |
+
equality-preserving [[concepts.equality]]; otherwise, `T` and `U` model
|
| 101 |
+
`totally_ordered_with`. For any expressions `ET` and `EU` such that
|
| 102 |
+
`decltype((ET))` is `T` and `decltype((EU))` is `U`, exactly one of
|
| 103 |
+
`ranges::less{}(ET, EU)`, `ranges::less{}(EU, ET)`, or
|
| 104 |
`ranges::equal_to{}(ET, EU)` is `true`.
|
| 105 |
|
| 106 |
*Effects:*
|
| 107 |
|
| 108 |
- If the expression `std::forward<T>(t) < std::forward<U>(u)` results in
|
|
|
|
| 114 |
`return std::forward<T>(t) < std::forward<U>(u);`
|
| 115 |
|
| 116 |
``` cpp
|
| 117 |
struct ranges::greater_equal {
|
| 118 |
template<class T, class U>
|
|
|
|
| 119 |
constexpr bool operator()(T&& t, U&& u) const;
|
| 120 |
|
| 121 |
using is_transparent = unspecified;
|
| 122 |
};
|
| 123 |
```
|
| 124 |
|
| 125 |
+
``` cpp
|
| 126 |
+
template<class T, class U>
|
| 127 |
+
constexpr bool operator()(T&& t, U&& u) const;
|
| 128 |
+
```
|
| 129 |
+
|
| 130 |
+
*Constraints:* `T` and `U` satisfy `totally_ordered_with`.
|
| 131 |
+
|
| 132 |
+
*Effects:* Equivalent to:
|
| 133 |
|
| 134 |
``` cpp
|
| 135 |
return !ranges::less{}(std::forward<T>(t), std::forward<U>(u));
|
| 136 |
```
|
| 137 |
|
| 138 |
``` cpp
|
| 139 |
struct ranges::less_equal {
|
| 140 |
template<class T, class U>
|
|
|
|
| 141 |
constexpr bool operator()(T&& t, U&& u) const;
|
| 142 |
|
| 143 |
using is_transparent = unspecified;
|
| 144 |
};
|
| 145 |
```
|
| 146 |
|
| 147 |
+
``` cpp
|
| 148 |
+
template<class T, class U>
|
| 149 |
+
constexpr bool operator()(T&& t, U&& u) const;
|
| 150 |
+
```
|
| 151 |
+
|
| 152 |
+
*Constraints:* `T` and `U` satisfy `totally_ordered_with`.
|
| 153 |
+
|
| 154 |
+
*Effects:* Equivalent to:
|
| 155 |
|
| 156 |
``` cpp
|
| 157 |
return !ranges::less{}(std::forward<U>(u), std::forward<T>(t));
|
| 158 |
```
|
| 159 |
|