- tmp/tmp_m2604y8/{from.md → to.md} +106 -77
tmp/tmp_m2604y8/{from.md → to.md}
RENAMED
|
@@ -30,11 +30,10 @@ struct I {
|
|
| 30 |
I operator++(int);
|
| 31 |
I& operator--();
|
| 32 |
I operator--(int);
|
| 33 |
|
| 34 |
bool operator==(I) const;
|
| 35 |
-
bool operator!=(I) const;
|
| 36 |
};
|
| 37 |
```
|
| 38 |
|
| 39 |
`iterator_traits<I>::iterator_category` denotes `input_iterator_tag`,
|
| 40 |
and `ITER_CONCEPT(I)` denotes `random_access_iterator_tag`.
|
|
@@ -69,14 +68,10 @@ template<class In>
|
|
| 69 |
```
|
| 70 |
|
| 71 |
Given a value `i` of type `I`, `I` models `indirectly_readable` only if
|
| 72 |
the expression `*i` is equality-preserving.
|
| 73 |
|
| 74 |
-
[*Note 1*: The expression `*i` is indirectly required to be valid via
|
| 75 |
-
the exposition-only `dereferenceable` concept
|
| 76 |
-
[[iterator.synopsis]]. — *end note*]
|
| 77 |
-
|
| 78 |
#### Concept <a id="iterator.concept.writable">[[iterator.concept.writable]]</a>
|
| 79 |
|
| 80 |
The `indirectly_writable` concept specifies the requirements for writing
|
| 81 |
a value into an iterator’s referenced object.
|
| 82 |
|
|
@@ -96,11 +91,11 @@ template<class Out, class T>
|
|
| 96 |
Let `E` be an expression such that `decltype((E))` is `T`, and let `o`
|
| 97 |
be a dereferenceable object of type `Out`. `Out` and `T` model
|
| 98 |
`indirectly_writable<Out, T>` only if
|
| 99 |
|
| 100 |
- If `Out` and `T` model
|
| 101 |
-
`indirectly_readable<Out> && same_as<iter_value_t<Out>, decay_t<T>
|
| 102 |
then `*o` after any above assignment is equal to the value of `E`
|
| 103 |
before the assignment.
|
| 104 |
|
| 105 |
After evaluating any above assignment expression, `o` is not required to
|
| 106 |
be dereferenceable.
|
|
@@ -126,99 +121,126 @@ that can be incremented with the pre- and post-increment operators. The
|
|
| 126 |
increment operations are not required to be equality-preserving, nor is
|
| 127 |
the type required to be `equality_comparable`.
|
| 128 |
|
| 129 |
``` cpp
|
| 130 |
template<class T>
|
| 131 |
-
|
| 132 |
|
| 133 |
template<class T>
|
| 134 |
-
|
| 135 |
|
| 136 |
template<class I>
|
| 137 |
concept weakly_incrementable =
|
| 138 |
-
|
| 139 |
requires(I i) {
|
| 140 |
typename iter_difference_t<I>;
|
| 141 |
requires is-signed-integer-like<iter_difference_t<I>>;
|
| 142 |
{ ++i } -> same_as<I&>; // not required to be equality-preserving
|
| 143 |
i++; // not required to be equality-preserving
|
| 144 |
};
|
| 145 |
```
|
| 146 |
|
| 147 |
A type `I` is an *integer-class type* if it is in a set of
|
| 148 |
-
implementation-defined
|
| 149 |
-
defined
|
|
|
|
|
|
|
|
|
|
| 150 |
|
| 151 |
The range of representable values of an integer-class type is the
|
| 152 |
-
continuous set of values over which it is defined.
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
*signed-integer-class type*
|
| 156 |
-
*unsigned-integer-class type*.
|
|
|
|
|
|
|
|
|
|
| 157 |
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
|
|
|
|
|
|
| 162 |
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
as `
|
| 166 |
-
type.
|
| 167 |
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 173 |
- For every assignment operator `@=` for which `c @= x` is well-formed,
|
| 174 |
`c @= a` shall also be well-formed and shall have the same value and
|
| 175 |
effects as `c @= x`. The expression `c @= a` shall be an lvalue
|
| 176 |
referring to `c`.
|
| 177 |
-
- For every
|
| 178 |
-
`a @ b` shall also be well-formed and shall have the same
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
|
|
|
|
|
|
|
|
|
| 187 |
|
| 188 |
An expression `E` of integer-class type `I` is contextually convertible
|
| 189 |
to `bool` as if by `bool(E != I(0))`.
|
| 190 |
|
| 191 |
All integer-class types model `regular` [[concepts.object]] and
|
| 192 |
-
`
|
| 193 |
|
| 194 |
A value-initialized object of integer-class type has value 0.
|
| 195 |
|
| 196 |
For every (possibly cv-qualified) integer-class type `I`,
|
| 197 |
-
`numeric_limits<I>` is specialized such that
|
|
|
|
|
|
|
| 198 |
|
| 199 |
-
- `
|
| 200 |
-
- `
|
| 201 |
-
|
| 202 |
-
- `
|
| 203 |
-
-
|
| 204 |
-
- `numeric_limits<I>::digits` is equal to the width of the integer-class
|
| 205 |
-
type,
|
| 206 |
-
- `numeric_limits<I>::digits10` is equal to
|
| 207 |
-
`static_cast<int>(digits * log10(2))`, and
|
| 208 |
-
- `numeric_limits<I>::min()` and `numeric_limits<I>::max()` return the
|
| 209 |
-
lowest and highest representable values of `I`, respectively, and
|
| 210 |
-
`numeric_limits<I>::lowest()` returns `numeric_limits<I>::{}min()`.
|
| 211 |
-
|
| 212 |
-
A type `I` is *integer-like* if it models `integral<I>` or if it is an
|
| 213 |
-
integer-class type. A type `I` is *signed-integer-like* if it models
|
| 214 |
-
`signed_integral<I>` or if it is a signed-integer-class type. A type `I`
|
| 215 |
-
is *unsigned-integer-like* if it models `unsigned_integral<I>` or if it
|
| 216 |
-
is an unsigned-integer-class type.
|
| 217 |
|
| 218 |
`is-integer-like<I>` is `true` if and only if `I` is an integer-like
|
| 219 |
-
type. `is-signed-integer-like<I>` is `true` if and only if I is a
|
| 220 |
signed-integer-like type.
|
| 221 |
|
| 222 |
Let `i` be an object of type `I`. When `i` is in the domain of both pre-
|
| 223 |
and post-increment, `i` is said to be *incrementable*. `I` models
|
| 224 |
`weakly_incrementable<I>` only if
|
|
@@ -227,17 +249,20 @@ and post-increment, `i` is said to be *incrementable*. `I` models
|
|
| 227 |
- If `i` is incrementable, then both `++i` and `i++` advance `i` to the
|
| 228 |
next element.
|
| 229 |
- If `i` is incrementable, then `addressof(++i)` is equal to
|
| 230 |
`addressof(i)`.
|
| 231 |
|
| 232 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 233 |
imply that `++a` equals `++b`. (Equality does not guarantee the
|
| 234 |
-
substitution property or referential transparency.)
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
algorithms can be used with istreams as the source of the input data
|
| 238 |
-
through the `istream_iterator` class template. — *end note*]
|
| 239 |
|
| 240 |
#### Concept <a id="iterator.concept.inc">[[iterator.concept.inc]]</a>
|
| 241 |
|
| 242 |
The `incrementable` concept specifies requirements on types that can be
|
| 243 |
incremented with the pre- and post-increment operators. The increment
|
|
@@ -274,13 +299,12 @@ The `input_or_output_iterator` concept forms the basis of the iterator
|
|
| 274 |
concept taxonomy; every iterator models `input_or_output_iterator`. This
|
| 275 |
concept specifies operations for dereferencing and incrementing an
|
| 276 |
iterator. Most algorithms will require additional operations to compare
|
| 277 |
iterators with sentinels [[iterator.concept.sentinel]], to read
|
| 278 |
[[iterator.concept.input]] or write [[iterator.concept.output]] values,
|
| 279 |
-
or to provide a richer set of iterator movements
|
| 280 |
-
[[iterator.concept.forward]], [[iterator.concept.bidir]],
|
| 281 |
-
[[iterator.concept.random.access]]).
|
| 282 |
|
| 283 |
``` cpp
|
| 284 |
template<class I>
|
| 285 |
concept input_or_output_iterator =
|
| 286 |
requires(I i) {
|
|
@@ -302,19 +326,20 @@ denote a range.
|
|
| 302 |
``` cpp
|
| 303 |
template<class S, class I>
|
| 304 |
concept sentinel_for =
|
| 305 |
semiregular<S> &&
|
| 306 |
input_or_output_iterator<I> &&
|
| 307 |
-
weakly-equality-comparable-with<S, I>;
|
| 308 |
```
|
| 309 |
|
| 310 |
Let `s` and `i` be values of type `S` and `I` such that \[`i`, `s`)
|
| 311 |
denotes a range. Types `S` and `I` model `sentinel_for<S, I>` only if
|
| 312 |
|
| 313 |
- `i == s` is well-defined.
|
| 314 |
- If `bool(i != s)` then `i` is dereferenceable and \[`++i`, `s`)
|
| 315 |
denotes a range.
|
|
|
|
| 316 |
|
| 317 |
The domain of `==` is not static. Given an iterator `i` and sentinel `s`
|
| 318 |
such that \[`i`, `s`) denotes a range and `i != s`, `i` and `s` are not
|
| 319 |
required to continue to denote a range after incrementing any other
|
| 320 |
iterator equal to `i`. Consequently, `i == s` is no longer required to
|
|
@@ -348,11 +373,11 @@ and `I` model `sized_sentinel_for<S, I>` only if
|
|
| 348 |
- If -N is representable by `iter_difference_t<I>`, then `i - s` is
|
| 349 |
well-defined and equals -N.
|
| 350 |
|
| 351 |
``` cpp
|
| 352 |
template<class S, class I>
|
| 353 |
-
|
| 354 |
```
|
| 355 |
|
| 356 |
*Remarks:* Pursuant to [[namespace.std]], users may specialize
|
| 357 |
`disable_sized_sentinel_for` for cv-unqualified non-array object types
|
| 358 |
`S` and `I` if `S` and/or `I` is a program-defined type. Such
|
|
@@ -416,13 +441,13 @@ be a dereferenceable object of type `I`. `I` and `T` model
|
|
| 416 |
``` cpp
|
| 417 |
*i = E;
|
| 418 |
++i;
|
| 419 |
```
|
| 420 |
|
| 421 |
-
|
| 422 |
-
through the same iterator twice
|
| 423 |
-
|
| 424 |
|
| 425 |
#### Concept <a id="iterator.concept.forward">[[iterator.concept.forward]]</a>
|
| 426 |
|
| 427 |
The `forward_iterator` concept adds copyability, equality comparison,
|
| 428 |
and the multi-pass guarantee, specified below.
|
|
@@ -450,11 +475,11 @@ range.
|
|
| 450 |
|
| 451 |
Two dereferenceable iterators `a` and `b` of type `X` offer the
|
| 452 |
*multi-pass guarantee* if:
|
| 453 |
|
| 454 |
- `a == b` implies `++a == ++b` and
|
| 455 |
-
-
|
| 456 |
expression `*a`.
|
| 457 |
|
| 458 |
[*Note 2*: The requirement that `a == b` implies `++a == ++b` and the
|
| 459 |
removal of the restrictions on the number of assignments through a
|
| 460 |
mutable iterator (which applies to output iterators) allow the use of
|
|
@@ -560,8 +585,12 @@ non-dereferenceable iterator of type `I` such that `b` is reachable from
|
|
| 560 |
`a` and `c` is reachable from `b`, and let `D` be
|
| 561 |
`iter_difference_t<I>`. The type `I` models `contiguous_iterator` only
|
| 562 |
if
|
| 563 |
|
| 564 |
- `to_address(a) == addressof(*a)`,
|
| 565 |
-
- `to_address(b) == to_address(a) + D(b - a)`,
|
| 566 |
-
- `to_address(c) == to_address(a) + D(c - a)`
|
|
|
|
|
|
|
|
|
|
|
|
|
| 567 |
|
|
|
|
| 30 |
I operator++(int);
|
| 31 |
I& operator--();
|
| 32 |
I operator--(int);
|
| 33 |
|
| 34 |
bool operator==(I) const;
|
|
|
|
| 35 |
};
|
| 36 |
```
|
| 37 |
|
| 38 |
`iterator_traits<I>::iterator_category` denotes `input_iterator_tag`,
|
| 39 |
and `ITER_CONCEPT(I)` denotes `random_access_iterator_tag`.
|
|
|
|
| 68 |
```
|
| 69 |
|
| 70 |
Given a value `i` of type `I`, `I` models `indirectly_readable` only if
|
| 71 |
the expression `*i` is equality-preserving.
|
| 72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
#### Concept <a id="iterator.concept.writable">[[iterator.concept.writable]]</a>
|
| 74 |
|
| 75 |
The `indirectly_writable` concept specifies the requirements for writing
|
| 76 |
a value into an iterator’s referenced object.
|
| 77 |
|
|
|
|
| 91 |
Let `E` be an expression such that `decltype((E))` is `T`, and let `o`
|
| 92 |
be a dereferenceable object of type `Out`. `Out` and `T` model
|
| 93 |
`indirectly_writable<Out, T>` only if
|
| 94 |
|
| 95 |
- If `Out` and `T` model
|
| 96 |
+
`indirectly_readable<Out> && same_as<iter_value_t<Out>, decay_t<T>>`,
|
| 97 |
then `*o` after any above assignment is equal to the value of `E`
|
| 98 |
before the assignment.
|
| 99 |
|
| 100 |
After evaluating any above assignment expression, `o` is not required to
|
| 101 |
be dereferenceable.
|
|
|
|
| 121 |
increment operations are not required to be equality-preserving, nor is
|
| 122 |
the type required to be `equality_comparable`.
|
| 123 |
|
| 124 |
``` cpp
|
| 125 |
template<class T>
|
| 126 |
+
constexpr bool is-integer-like = see below; // exposition only
|
| 127 |
|
| 128 |
template<class T>
|
| 129 |
+
constexpr bool is-signed-integer-like = see below; // exposition only
|
| 130 |
|
| 131 |
template<class I>
|
| 132 |
concept weakly_incrementable =
|
| 133 |
+
movable<I> &&
|
| 134 |
requires(I i) {
|
| 135 |
typename iter_difference_t<I>;
|
| 136 |
requires is-signed-integer-like<iter_difference_t<I>>;
|
| 137 |
{ ++i } -> same_as<I&>; // not required to be equality-preserving
|
| 138 |
i++; // not required to be equality-preserving
|
| 139 |
};
|
| 140 |
```
|
| 141 |
|
| 142 |
A type `I` is an *integer-class type* if it is in a set of
|
| 143 |
+
*implementation-defined* types that behave as integer types do, as
|
| 144 |
+
defined below.
|
| 145 |
+
|
| 146 |
+
[*Note 1*: An integer-class type is not necessarily a class
|
| 147 |
+
type. — *end note*]
|
| 148 |
|
| 149 |
The range of representable values of an integer-class type is the
|
| 150 |
+
continuous set of values over which it is defined. For any integer-class
|
| 151 |
+
type, its range of representable values is either -2ᴺ⁻¹ to 2ᴺ⁻¹-1
|
| 152 |
+
(inclusive) for some integer N, in which case it is a
|
| 153 |
+
*signed-integer-class type*, or 0 to 2ᴺ-1 (inclusive) for some integer
|
| 154 |
+
N, in which case it is an *unsigned-integer-class type*. In both cases,
|
| 155 |
+
N is called the *width* of the integer-class type. The width of an
|
| 156 |
+
integer-class type is greater than that of every integral type of the
|
| 157 |
+
same signedness.
|
| 158 |
|
| 159 |
+
A type `I` other than cv `bool` is *integer-like* if it models
|
| 160 |
+
`integral<I>` or if it is an integer-class type. An integer-like type
|
| 161 |
+
`I` is *signed-integer-like* if it models `signed_integral<I>` or if it
|
| 162 |
+
is a signed-integer-class type. An integer-like type `I` is
|
| 163 |
+
*unsigned-integer-like* if it models `unsigned_integral<I>` or if it is
|
| 164 |
+
an unsigned-integer-class type.
|
| 165 |
|
| 166 |
+
For every integer-class type `I`, let `B(I)` be a unique hypothetical
|
| 167 |
+
extended integer type of the same signedness with the same width
|
| 168 |
+
[[basic.fundamental]] as `I`.
|
|
|
|
| 169 |
|
| 170 |
+
[*Note 2*: The corresponding hypothetical specialization
|
| 171 |
+
`numeric_limits<B(I)>` meets the requirements on `numeric_limits`
|
| 172 |
+
specializations for integral types [[numeric.limits]]. — *end note*]
|
| 173 |
+
|
| 174 |
+
For every integral type `J`, let `B(J)` be the same type as `J`.
|
| 175 |
+
|
| 176 |
+
Expressions of integer-class type are explicitly convertible to any
|
| 177 |
+
integer-like type, and implicitly convertible to any integer-class type
|
| 178 |
+
of equal or greater width and the same signedness. Expressions of
|
| 179 |
+
integral type are both implicitly and explicitly convertible to any
|
| 180 |
+
integer-class type. Conversions between integral and integer-class types
|
| 181 |
+
and between two integer-class types do not exit via an exception. The
|
| 182 |
+
result of such a conversion is the unique value of the destination type
|
| 183 |
+
that is congruent to the source modulo 2ᴺ, where N is the width of the
|
| 184 |
+
destination type.
|
| 185 |
+
|
| 186 |
+
Let `a` be an object of integer-class type `I`, let `b` be an object of
|
| 187 |
+
integer-like type `I2` such that the expression `b` is implicitly
|
| 188 |
+
convertible to `I`, let `x` and `y` be, respectively, objects of type
|
| 189 |
+
`B(I)` and `B(I2)` as described above that represent the same values as
|
| 190 |
+
`a` and `b`, and let `c` be an lvalue of any integral type.
|
| 191 |
+
|
| 192 |
+
- The expressions `a++` and `a--` shall be prvalues of type `I` whose
|
| 193 |
+
values are equal to that of `a` prior to the evaluation of the
|
| 194 |
+
expressions. The expression `a++` shall modify the value of `a` by
|
| 195 |
+
adding `1` to it. The expression `a--` shall modify the value of `a`
|
| 196 |
+
by subtracting `1` from it.
|
| 197 |
+
- The expressions `++a`, `--a`, and `&a` shall be expression-equivalent
|
| 198 |
+
to `a += 1`, `a -= 1`, and `addressof(a)`, respectively.
|
| 199 |
+
- For every *unary-operator* `@` other than `&` for which the expression
|
| 200 |
+
`@x` is well-formed, `@a` shall also be well-formed and have the same
|
| 201 |
+
value, effects, and value category as `@x`. If `@x` has type `bool`,
|
| 202 |
+
so too does `@a`; if `@x` has type `B(I)`, then `@a` has type `I`.
|
| 203 |
- For every assignment operator `@=` for which `c @= x` is well-formed,
|
| 204 |
`c @= a` shall also be well-formed and shall have the same value and
|
| 205 |
effects as `c @= x`. The expression `c @= a` shall be an lvalue
|
| 206 |
referring to `c`.
|
| 207 |
+
- For every assignment operator `@=` for which `x @= y` is well-formed,
|
| 208 |
+
`a @= b` shall also be well-formed and shall have the same effects as
|
| 209 |
+
`x @= y`, except that the value that would be stored into `x` is
|
| 210 |
+
stored into `a`. The expression `a @= b` shall be an lvalue referring
|
| 211 |
+
to `a`.
|
| 212 |
+
- For every non-assignment binary operator `@` for which `x @ y` and
|
| 213 |
+
`y @ x` are well-formed, `a @ b` and `b @ a` shall also be well-formed
|
| 214 |
+
and shall have the same value, effects, and value category as `x @ y`
|
| 215 |
+
and `y @ x`, respectively. If `x @ y` or `y @ x` has type `B(I)`, then
|
| 216 |
+
`a @ b` or `b @ a`, respectively, has type `I`; if `x @ y` or `y @ x`
|
| 217 |
+
has type `B(I2)`, then `a @ b` or `b @ a`, respectively, has type
|
| 218 |
+
`I2`; if `x @ y` or `y @ x` has any other type, then `a @ b` or
|
| 219 |
+
`b @ a`, respectively, has that type.
|
| 220 |
|
| 221 |
An expression `E` of integer-class type `I` is contextually convertible
|
| 222 |
to `bool` as if by `bool(E != I(0))`.
|
| 223 |
|
| 224 |
All integer-class types model `regular` [[concepts.object]] and
|
| 225 |
+
`three_way_comparable<strong_ordering>` [[cmp.concept]].
|
| 226 |
|
| 227 |
A value-initialized object of integer-class type has value 0.
|
| 228 |
|
| 229 |
For every (possibly cv-qualified) integer-class type `I`,
|
| 230 |
+
`numeric_limits<I>` is specialized such that each static data member `m`
|
| 231 |
+
has the same value as `numeric_limits<B(I)>::m`, and each static member
|
| 232 |
+
function `f` returns `I(numeric_limits<B(I)>::f())`.
|
| 233 |
|
| 234 |
+
For any two integer-like types `I1` and `I2`, at least one of which is
|
| 235 |
+
an integer-class type, `common_type_t<I1, I2>` denotes an integer-class
|
| 236 |
+
type whose width is not less than that of `I1` or `I2`. If both `I1` and
|
| 237 |
+
`I2` are signed-integer-like types, then `common_type_t<I1, I2>` is also
|
| 238 |
+
a signed-integer-like type.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 239 |
|
| 240 |
`is-integer-like<I>` is `true` if and only if `I` is an integer-like
|
| 241 |
+
type. `is-signed-integer-like<I>` is `true` if and only if `I` is a
|
| 242 |
signed-integer-like type.
|
| 243 |
|
| 244 |
Let `i` be an object of type `I`. When `i` is in the domain of both pre-
|
| 245 |
and post-increment, `i` is said to be *incrementable*. `I` models
|
| 246 |
`weakly_incrementable<I>` only if
|
|
|
|
| 249 |
- If `i` is incrementable, then both `++i` and `i++` advance `i` to the
|
| 250 |
next element.
|
| 251 |
- If `i` is incrementable, then `addressof(++i)` is equal to
|
| 252 |
`addressof(i)`.
|
| 253 |
|
| 254 |
+
*Recommended practice:* The implementaton of an algorithm on a weakly
|
| 255 |
+
incrementable type should never attempt to pass through the same
|
| 256 |
+
incrementable value twice; such an algorithm should be a single-pass
|
| 257 |
+
algorithm.
|
| 258 |
+
|
| 259 |
+
[*Note 3*: For `weakly_incrementable` types, `a` equals `b` does not
|
| 260 |
imply that `++a` equals `++b`. (Equality does not guarantee the
|
| 261 |
+
substitution property or referential transparency.) Such algorithms can
|
| 262 |
+
be used with istreams as the source of the input data through the
|
| 263 |
+
`istream_iterator` class template. — *end note*]
|
|
|
|
|
|
|
| 264 |
|
| 265 |
#### Concept <a id="iterator.concept.inc">[[iterator.concept.inc]]</a>
|
| 266 |
|
| 267 |
The `incrementable` concept specifies requirements on types that can be
|
| 268 |
incremented with the pre- and post-increment operators. The increment
|
|
|
|
| 299 |
concept taxonomy; every iterator models `input_or_output_iterator`. This
|
| 300 |
concept specifies operations for dereferencing and incrementing an
|
| 301 |
iterator. Most algorithms will require additional operations to compare
|
| 302 |
iterators with sentinels [[iterator.concept.sentinel]], to read
|
| 303 |
[[iterator.concept.input]] or write [[iterator.concept.output]] values,
|
| 304 |
+
or to provide a richer set of iterator movements
|
| 305 |
+
[[iterator.concept.forward]], [[iterator.concept.bidir]], [[iterator.concept.random.access]].
|
|
|
|
| 306 |
|
| 307 |
``` cpp
|
| 308 |
template<class I>
|
| 309 |
concept input_or_output_iterator =
|
| 310 |
requires(I i) {
|
|
|
|
| 326 |
``` cpp
|
| 327 |
template<class S, class I>
|
| 328 |
concept sentinel_for =
|
| 329 |
semiregular<S> &&
|
| 330 |
input_or_output_iterator<I> &&
|
| 331 |
+
weakly-equality-comparable-with<S, I>; // see [concept.equalitycomparable]
|
| 332 |
```
|
| 333 |
|
| 334 |
Let `s` and `i` be values of type `S` and `I` such that \[`i`, `s`)
|
| 335 |
denotes a range. Types `S` and `I` model `sentinel_for<S, I>` only if
|
| 336 |
|
| 337 |
- `i == s` is well-defined.
|
| 338 |
- If `bool(i != s)` then `i` is dereferenceable and \[`++i`, `s`)
|
| 339 |
denotes a range.
|
| 340 |
+
- `assignable_from<I&, S>` is either modeled or not satisfied.
|
| 341 |
|
| 342 |
The domain of `==` is not static. Given an iterator `i` and sentinel `s`
|
| 343 |
such that \[`i`, `s`) denotes a range and `i != s`, `i` and `s` are not
|
| 344 |
required to continue to denote a range after incrementing any other
|
| 345 |
iterator equal to `i`. Consequently, `i == s` is no longer required to
|
|
|
|
| 373 |
- If -N is representable by `iter_difference_t<I>`, then `i - s` is
|
| 374 |
well-defined and equals -N.
|
| 375 |
|
| 376 |
``` cpp
|
| 377 |
template<class S, class I>
|
| 378 |
+
constexpr bool disable_sized_sentinel_for = false;
|
| 379 |
```
|
| 380 |
|
| 381 |
*Remarks:* Pursuant to [[namespace.std]], users may specialize
|
| 382 |
`disable_sized_sentinel_for` for cv-unqualified non-array object types
|
| 383 |
`S` and `I` if `S` and/or `I` is a program-defined type. Such
|
|
|
|
| 441 |
``` cpp
|
| 442 |
*i = E;
|
| 443 |
++i;
|
| 444 |
```
|
| 445 |
|
| 446 |
+
*Recommended practice:* The implementation of an algorithm on output
|
| 447 |
+
iterators should never attempt to pass through the same iterator twice;
|
| 448 |
+
such an algorithm should be a single-pass algorithm.
|
| 449 |
|
| 450 |
#### Concept <a id="iterator.concept.forward">[[iterator.concept.forward]]</a>
|
| 451 |
|
| 452 |
The `forward_iterator` concept adds copyability, equality comparison,
|
| 453 |
and the multi-pass guarantee, specified below.
|
|
|
|
| 475 |
|
| 476 |
Two dereferenceable iterators `a` and `b` of type `X` offer the
|
| 477 |
*multi-pass guarantee* if:
|
| 478 |
|
| 479 |
- `a == b` implies `++a == ++b` and
|
| 480 |
+
- the expression `((void)[](X x){++x;}(a), *a)` is equivalent to the
|
| 481 |
expression `*a`.
|
| 482 |
|
| 483 |
[*Note 2*: The requirement that `a == b` implies `++a == ++b` and the
|
| 484 |
removal of the restrictions on the number of assignments through a
|
| 485 |
mutable iterator (which applies to output iterators) allow the use of
|
|
|
|
| 585 |
`a` and `c` is reachable from `b`, and let `D` be
|
| 586 |
`iter_difference_t<I>`. The type `I` models `contiguous_iterator` only
|
| 587 |
if
|
| 588 |
|
| 589 |
- `to_address(a) == addressof(*a)`,
|
| 590 |
+
- `to_address(b) == to_address(a) + D(b - a)`,
|
| 591 |
+
- `to_address(c) == to_address(a) + D(c - a)`,
|
| 592 |
+
- `ranges::iter_move(a)` has the same type, value category, and effects
|
| 593 |
+
as `std::move(*a)`, and
|
| 594 |
+
- if `ranges::iter_swap(a, b)` is well-formed, it has effects equivalent
|
| 595 |
+
to `ranges::swap(*a, *b)`.
|
| 596 |
|