tmp/tmpr1z01_p4/{from.md → to.md}
RENAMED
|
@@ -12,38 +12,12 @@ possible for a concrete iterator type.
|
|
| 12 |
`random_access_iterator` forward `n` steps in constant time. For an
|
| 13 |
iterator type that does not model `random_access_iterator`,
|
| 14 |
`ranges::advance` instead performs `n` individual increments with the
|
| 15 |
`++` operator. — *end example*]
|
| 16 |
|
| 17 |
-
The
|
| 18 |
-
|
| 19 |
-
unqualified [[basic.lookup.unqual]] name lookup for the
|
| 20 |
-
*postfix-expression* in a function call [[expr.call]], they inhibit
|
| 21 |
-
argument-dependent name lookup.
|
| 22 |
-
|
| 23 |
-
[*Example 2*:
|
| 24 |
-
|
| 25 |
-
``` cpp
|
| 26 |
-
void foo() {
|
| 27 |
-
using namespace std::ranges;
|
| 28 |
-
std::vector<int> vec{1,2,3};
|
| 29 |
-
distance(begin(vec), end(vec)); // #1
|
| 30 |
-
}
|
| 31 |
-
```
|
| 32 |
-
|
| 33 |
-
The function call expression at `#1` invokes `std::ranges::distance`,
|
| 34 |
-
not `std::distance`, despite that (a) the iterator type returned from
|
| 35 |
-
`begin(vec)` and `end(vec)` may be associated with namespace `std` and
|
| 36 |
-
(b) `std::distance` is more specialized [[temp.func.order]] than
|
| 37 |
-
`std::ranges::distance` since the former requires its first two
|
| 38 |
-
parameters to have the same type.
|
| 39 |
-
|
| 40 |
-
— *end example*]
|
| 41 |
-
|
| 42 |
-
The number and order of deducible template parameters for the function
|
| 43 |
-
templates defined in [[range.iter.ops]] is unspecified, except where
|
| 44 |
-
explicitly stated otherwise.
|
| 45 |
|
| 46 |
#### `ranges::advance` <a id="range.iter.op.advance">[[range.iter.op.advance]]</a>
|
| 47 |
|
| 48 |
``` cpp
|
| 49 |
template<input_or_output_iterator I>
|
|
@@ -117,11 +91,17 @@ number of increments.
|
|
| 117 |
template<class I, sized_sentinel_for<decay_t<I>> S>
|
| 118 |
constexpr iter_difference_t<decay_t<I>> ranges::distance(I&& first, S last);
|
| 119 |
```
|
| 120 |
|
| 121 |
*Effects:* Equivalent to:
|
| 122 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
|
| 124 |
``` cpp
|
| 125 |
template<range R>
|
| 126 |
constexpr range_difference_t<R> ranges::distance(R&& r);
|
| 127 |
```
|
|
|
|
| 12 |
`random_access_iterator` forward `n` steps in constant time. For an
|
| 13 |
iterator type that does not model `random_access_iterator`,
|
| 14 |
`ranges::advance` instead performs `n` individual increments with the
|
| 15 |
`++` operator. — *end example*]
|
| 16 |
|
| 17 |
+
The entities defined in [[range.iter.ops]] are algorithm function
|
| 18 |
+
objects [[alg.func.obj]].
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
#### `ranges::advance` <a id="range.iter.op.advance">[[range.iter.op.advance]]</a>
|
| 21 |
|
| 22 |
``` cpp
|
| 23 |
template<input_or_output_iterator I>
|
|
|
|
| 91 |
template<class I, sized_sentinel_for<decay_t<I>> S>
|
| 92 |
constexpr iter_difference_t<decay_t<I>> ranges::distance(I&& first, S last);
|
| 93 |
```
|
| 94 |
|
| 95 |
*Effects:* Equivalent to:
|
| 96 |
+
|
| 97 |
+
``` cpp
|
| 98 |
+
if constexpr (!is_array_v<remove_reference_t<I>>)
|
| 99 |
+
return last - first;
|
| 100 |
+
else
|
| 101 |
+
return last - static_cast<decay_t<I>>(first);
|
| 102 |
+
```
|
| 103 |
|
| 104 |
``` cpp
|
| 105 |
template<range R>
|
| 106 |
constexpr range_difference_t<R> ranges::distance(R&& r);
|
| 107 |
```
|