tmp/tmpwsb16lev/{from.md → to.md}
RENAMED
|
@@ -39,14 +39,10 @@ template<class T>
|
|
| 39 |
ranges::begin(t); // sometimes equality-preserving (see below)
|
| 40 |
ranges::end(t);
|
| 41 |
};
|
| 42 |
```
|
| 43 |
|
| 44 |
-
The required expressions `ranges::begin(t)` and `ranges::end(t)` of the
|
| 45 |
-
`range` concept do not require implicit expression
|
| 46 |
-
variations [[concepts.equality]].
|
| 47 |
-
|
| 48 |
Given an expression `t` such that `decltype((t))` is `T&`, `T` models
|
| 49 |
`range` only if
|
| 50 |
|
| 51 |
- \[`ranges::begin(t)`, `ranges::end(t)`) denotes a
|
| 52 |
range [[iterator.requirements.general]],
|
|
@@ -100,20 +96,48 @@ models `borrowed_range` because
|
|
| 100 |
- `S`’s iterators do not have validity tied to the lifetime of an `S`
|
| 101 |
object because they are “borrowed” from some other range.
|
| 102 |
|
| 103 |
— *end example*]
|
| 104 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
### Sized ranges <a id="range.sized">[[range.sized]]</a>
|
| 106 |
|
| 107 |
-
The `sized_range` concept refines `
|
| 108 |
-
number of elements in the range can be determined
|
| 109 |
-
time using `ranges::size`.
|
| 110 |
|
| 111 |
``` cpp
|
| 112 |
template<class T>
|
| 113 |
concept sized_range =
|
| 114 |
-
|
| 115 |
```
|
| 116 |
|
| 117 |
Given an lvalue `t` of type `remove_reference_t<T>`, `T` models
|
| 118 |
`sized_range` only if
|
| 119 |
|
|
@@ -135,11 +159,11 @@ template<class>
|
|
| 135 |
*Remarks:* Pursuant to [[namespace.std]], users may specialize
|
| 136 |
`disable_sized_range` for cv-unqualified program-defined types. Such
|
| 137 |
specializations shall be usable in constant expressions [[expr.const]]
|
| 138 |
and have type `const bool`.
|
| 139 |
|
| 140 |
-
[*Note 1*: `disable_sized_range` allows use of range types with the
|
| 141 |
library that satisfy but do not in fact model
|
| 142 |
`sized_range`. — *end note*]
|
| 143 |
|
| 144 |
### Views <a id="range.view">[[range.view]]</a>
|
| 145 |
|
|
@@ -151,11 +175,11 @@ constructing range adaptor pipelines [[range.adaptors]].
|
|
| 151 |
template<class T>
|
| 152 |
concept view =
|
| 153 |
range<T> && movable<T> && enable_view<T>;
|
| 154 |
```
|
| 155 |
|
| 156 |
-
`T` models `view` only if
|
| 157 |
|
| 158 |
- `T` has 𝑂(1) move construction; and
|
| 159 |
- move assignment of an object of type `T` is no more complex than
|
| 160 |
destruction followed by move construction; and
|
| 161 |
- if N copies and/or moves are made from an object of type `T` that
|
|
@@ -199,12 +223,12 @@ For a type `T`, *`is-derived-from-view-interface`*`<T>` is `true` if and
|
|
| 199 |
only if `T` has exactly one public base class `view_interface<U>` for
|
| 200 |
some type `U` and `T` has no base classes of type `view_interface<V>`
|
| 201 |
for any other type `V`.
|
| 202 |
|
| 203 |
*Remarks:* Pursuant to [[namespace.std]], users may specialize
|
| 204 |
-
`enable_view` to `true` for cv-unqualified program-defined types
|
| 205 |
-
model `view`, and `false` for types
|
| 206 |
shall be usable in constant expressions [[expr.const]] and have type
|
| 207 |
`const bool`.
|
| 208 |
|
| 209 |
### Other range refinements <a id="range.refinements">[[range.refinements]]</a>
|
| 210 |
|
|
@@ -290,5 +314,18 @@ type whose elements are not modifiable.
|
|
| 290 |
template<class T>
|
| 291 |
concept constant_range =
|
| 292 |
input_range<T> && constant-iterator<iterator_t<T>>;
|
| 293 |
```
|
| 294 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
ranges::begin(t); // sometimes equality-preserving (see below)
|
| 40 |
ranges::end(t);
|
| 41 |
};
|
| 42 |
```
|
| 43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
Given an expression `t` such that `decltype((t))` is `T&`, `T` models
|
| 45 |
`range` only if
|
| 46 |
|
| 47 |
- \[`ranges::begin(t)`, `ranges::end(t)`) denotes a
|
| 48 |
range [[iterator.requirements.general]],
|
|
|
|
| 96 |
- `S`’s iterators do not have validity tied to the lifetime of an `S`
|
| 97 |
object because they are “borrowed” from some other range.
|
| 98 |
|
| 99 |
— *end example*]
|
| 100 |
|
| 101 |
+
### Approximately sized ranges <a id="range.approximately.sized">[[range.approximately.sized]]</a>
|
| 102 |
+
|
| 103 |
+
The `approximately_sized_range` concept refines `range` with the
|
| 104 |
+
requirement that an approximation of the number of elements in the range
|
| 105 |
+
can be determined in amortized constant time using
|
| 106 |
+
`ranges::reserve_hint`.
|
| 107 |
+
|
| 108 |
+
``` cpp
|
| 109 |
+
template<class T>
|
| 110 |
+
concept approximately_sized_range =
|
| 111 |
+
range<T> && requires(T& t) { ranges::reserve_hint(t); };
|
| 112 |
+
```
|
| 113 |
+
|
| 114 |
+
Given an lvalue `t` of type `remove_reference_t<T>`, `T` models
|
| 115 |
+
`approximately_sized_range` only if
|
| 116 |
+
|
| 117 |
+
- `ranges::reserve_hint(t)` is amortized 𝑂(1), does not modify `t`, and
|
| 118 |
+
has a value that is not negative and is representable in
|
| 119 |
+
`range_difference_t<T>`, and
|
| 120 |
+
- if `iterator_t<T>` models `forward_iterator`,
|
| 121 |
+
`ranges::reserve_hint(t)` is well-defined regardless of the evaluation
|
| 122 |
+
of `ranges::begin(t)`. \[*Note 1*: `ranges::reserve_hint(t)` is
|
| 123 |
+
otherwise not required to be well-defined after evaluating
|
| 124 |
+
`ranges::begin(t)`. For example, it is possible for
|
| 125 |
+
`ranges::reserve_hint(t)` to be well-defined for an whose iterator
|
| 126 |
+
type does not model `forward_iterator` only if evaluated before the
|
| 127 |
+
first call to `ranges::begin(t)`. — *end note*]
|
| 128 |
+
|
| 129 |
### Sized ranges <a id="range.sized">[[range.sized]]</a>
|
| 130 |
|
| 131 |
+
The `sized_range` concept refines `approximately_sized_range` with the
|
| 132 |
+
requirement that the number of elements in the range can be determined
|
| 133 |
+
in amortized constant time using `ranges::size`.
|
| 134 |
|
| 135 |
``` cpp
|
| 136 |
template<class T>
|
| 137 |
concept sized_range =
|
| 138 |
+
approximately_sized_range<T> && requires(T& t) { ranges::size(t); };
|
| 139 |
```
|
| 140 |
|
| 141 |
Given an lvalue `t` of type `remove_reference_t<T>`, `T` models
|
| 142 |
`sized_range` only if
|
| 143 |
|
|
|
|
| 159 |
*Remarks:* Pursuant to [[namespace.std]], users may specialize
|
| 160 |
`disable_sized_range` for cv-unqualified program-defined types. Such
|
| 161 |
specializations shall be usable in constant expressions [[expr.const]]
|
| 162 |
and have type `const bool`.
|
| 163 |
|
| 164 |
+
[*Note 1*: `disable_sized_range` allows use of `range` types with the
|
| 165 |
library that satisfy but do not in fact model
|
| 166 |
`sized_range`. — *end note*]
|
| 167 |
|
| 168 |
### Views <a id="range.view">[[range.view]]</a>
|
| 169 |
|
|
|
|
| 175 |
template<class T>
|
| 176 |
concept view =
|
| 177 |
range<T> && movable<T> && enable_view<T>;
|
| 178 |
```
|
| 179 |
|
| 180 |
+
`T` models `view` only if
|
| 181 |
|
| 182 |
- `T` has 𝑂(1) move construction; and
|
| 183 |
- move assignment of an object of type `T` is no more complex than
|
| 184 |
destruction followed by move construction; and
|
| 185 |
- if N copies and/or moves are made from an object of type `T` that
|
|
|
|
| 223 |
only if `T` has exactly one public base class `view_interface<U>` for
|
| 224 |
some type `U` and `T` has no base classes of type `view_interface<V>`
|
| 225 |
for any other type `V`.
|
| 226 |
|
| 227 |
*Remarks:* Pursuant to [[namespace.std]], users may specialize
|
| 228 |
+
`enable_view` to `true` for cv-unqualified program-defined types that
|
| 229 |
+
model `view`, and `false` for types that do not. Such specializations
|
| 230 |
shall be usable in constant expressions [[expr.const]] and have type
|
| 231 |
`const bool`.
|
| 232 |
|
| 233 |
### Other range refinements <a id="range.refinements">[[range.refinements]]</a>
|
| 234 |
|
|
|
|
| 314 |
template<class T>
|
| 315 |
concept constant_range =
|
| 316 |
input_range<T> && constant-iterator<iterator_t<T>>;
|
| 317 |
```
|
| 318 |
|
| 319 |
+
The exposition-only concept `sized-random-access-range` specifies the
|
| 320 |
+
requirements of a `range` type that is sized and allows random access to
|
| 321 |
+
its elements.
|
| 322 |
+
|
| 323 |
+
``` cpp
|
| 324 |
+
template<class T>
|
| 325 |
+
concept sized-random-access-range = // exposition only
|
| 326 |
+
random_access_range<T> && sized_range<T>;
|
| 327 |
+
```
|
| 328 |
+
|
| 329 |
+
[*Note 1*: This concept constrains some parallel algorithm overloads;
|
| 330 |
+
see [[algorithms]]. — *end note*]
|
| 331 |
+
|