tmp/tmpq85bga9o/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#### Concept <a id="iterator.concept.sizedsentinel">[[iterator.concept.sizedsentinel]]</a>
|
| 2 |
+
|
| 3 |
+
The `sized_sentinel_for` concept specifies requirements on an
|
| 4 |
+
`input_or_output_iterator` type `I` and a corresponding
|
| 5 |
+
`sentinel_for<I>` that allow the use of the `-` operator to compute the
|
| 6 |
+
distance between them in constant time.
|
| 7 |
+
|
| 8 |
+
``` cpp
|
| 9 |
+
template<class S, class I>
|
| 10 |
+
concept sized_sentinel_for =
|
| 11 |
+
sentinel_for<S, I> &&
|
| 12 |
+
!disable_sized_sentinel_for<remove_cv_t<S>, remove_cv_t<I>> &&
|
| 13 |
+
requires(const I& i, const S& s) {
|
| 14 |
+
{ s - i } -> same_as<iter_difference_t<I>>;
|
| 15 |
+
{ i - s } -> same_as<iter_difference_t<I>>;
|
| 16 |
+
};
|
| 17 |
+
```
|
| 18 |
+
|
| 19 |
+
Let `i` be an iterator of type `I`, and `s` a sentinel of type `S` such
|
| 20 |
+
that \[`i`, `s`) denotes a range. Let N be the smallest number of
|
| 21 |
+
applications of `++i` necessary to make `bool(i == s)` be `true`. `S`
|
| 22 |
+
and `I` model `sized_sentinel_for<S, I>` only if
|
| 23 |
+
|
| 24 |
+
- If N is representable by `iter_difference_t<I>`, then `s - i` is
|
| 25 |
+
well-defined and equals N.
|
| 26 |
+
- If -N is representable by `iter_difference_t<I>`, then `i - s` is
|
| 27 |
+
well-defined and equals -N.
|
| 28 |
+
|
| 29 |
+
``` cpp
|
| 30 |
+
template<class S, class I>
|
| 31 |
+
inline constexpr bool disable_sized_sentinel_for = false;
|
| 32 |
+
```
|
| 33 |
+
|
| 34 |
+
*Remarks:* Pursuant to [[namespace.std]], users may specialize
|
| 35 |
+
`disable_sized_sentinel_for` for cv-unqualified non-array object types
|
| 36 |
+
`S` and `I` if `S` and/or `I` is a program-defined type. Such
|
| 37 |
+
specializations shall be usable in constant expressions [[expr.const]]
|
| 38 |
+
and have type `const bool`.
|
| 39 |
+
|
| 40 |
+
[*Note 1*: `disable_sized_sentinel_for` allows use of sentinels and
|
| 41 |
+
iterators with the library that satisfy but do not in fact model
|
| 42 |
+
`sized_sentinel_for`. — *end note*]
|
| 43 |
+
|
| 44 |
+
[*Example 1*: The `sized_sentinel_for` concept is modeled by pairs of
|
| 45 |
+
`random_access_iterator`s [[iterator.concept.random.access]] and by
|
| 46 |
+
counted iterators and their
|
| 47 |
+
sentinels [[counted.iterator]]. — *end example*]
|
| 48 |
+
|