tmp/tmpnopll0nq/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#### General <a id="range.iter.ops.general">[[range.iter.ops.general]]</a>
|
| 2 |
+
|
| 3 |
+
The library includes the function templates `ranges::advance`,
|
| 4 |
+
`ranges::distance`, `ranges::next`, and `ranges::prev` to manipulate
|
| 5 |
+
iterators. These operations adapt to the set of operators provided by
|
| 6 |
+
each iterator category to provide the most efficient implementation
|
| 7 |
+
possible for a concrete iterator type.
|
| 8 |
+
|
| 9 |
+
[*Example 1*: `ranges::advance` uses the `+` operator to move a
|
| 10 |
+
`random_access_iterator` forward `n` steps in constant time. For an
|
| 11 |
+
iterator type that does not model `random_access_iterator`,
|
| 12 |
+
`ranges::advance` instead performs `n` individual increments with the
|
| 13 |
+
`++` operator. — *end example*]
|
| 14 |
+
|
| 15 |
+
The function templates defined in [[range.iter.ops]] are not found by
|
| 16 |
+
argument-dependent name lookup [[basic.lookup.argdep]]. When found by
|
| 17 |
+
unqualified [[basic.lookup.unqual]] name lookup for the
|
| 18 |
+
*postfix-expression* in a function call [[expr.call]], they inhibit
|
| 19 |
+
argument-dependent name lookup.
|
| 20 |
+
|
| 21 |
+
[*Example 2*:
|
| 22 |
+
|
| 23 |
+
``` cpp
|
| 24 |
+
void foo() {
|
| 25 |
+
using namespace std::ranges;
|
| 26 |
+
std::vector<int> vec{1,2,3};
|
| 27 |
+
distance(begin(vec), end(vec)); // #1
|
| 28 |
+
}
|
| 29 |
+
```
|
| 30 |
+
|
| 31 |
+
The function call expression at `#1` invokes `std::ranges::distance`,
|
| 32 |
+
not `std::distance`, despite that (a) the iterator type returned from
|
| 33 |
+
`begin(vec)` and `end(vec)` may be associated with namespace `std` and
|
| 34 |
+
(b) `std::distance` is more specialized [[temp.func.order]] than
|
| 35 |
+
`std::ranges::distance` since the former requires its first two
|
| 36 |
+
parameters to have the same type.
|
| 37 |
+
|
| 38 |
+
— *end example*]
|
| 39 |
+
|
| 40 |
+
The number and order of deducible template parameters for the function
|
| 41 |
+
templates defined in [[range.iter.ops]] is unspecified, except where
|
| 42 |
+
explicitly stated otherwise.
|
| 43 |
+
|