From Jason Turner

[range.iter.op.distance]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp7xs52wy1/{from.md → to.md} +13 -7
tmp/tmp7xs52wy1/{from.md → to.md} RENAMED
@@ -1,19 +1,25 @@
1
  #### `ranges::distance` <a id="range.iter.op.distance">[[range.iter.op.distance]]</a>
2
 
3
  ``` cpp
4
- template<input_or_output_iterator I, sentinel_for<I> S>
 
5
  constexpr iter_difference_t<I> ranges::distance(I first, S last);
6
  ```
7
 
8
- *Preconditions:* \[`first`, `last`) denotes a range, or \[`last`,
9
- `first`) denotes a range and `S` and `I` model
10
- `same_as<S, I> && sized_sentinel_for<S, I>`.
11
 
12
- *Effects:* If `S` and `I` model `sized_sentinel_for<S, I>`, returns
13
- `(last - first)`; otherwise, returns the number of increments needed to
14
- get from `first` to `last`.
 
 
 
 
 
 
 
15
 
16
  ``` cpp
17
  template<range R>
18
  constexpr range_difference_t<R> ranges::distance(R&& r);
19
  ```
 
1
  #### `ranges::distance` <a id="range.iter.op.distance">[[range.iter.op.distance]]</a>
2
 
3
  ``` cpp
4
+ template<class I, sentinel_for<I> S>
5
+ requires (!sized_sentinel_for<S, I>)
6
  constexpr iter_difference_t<I> ranges::distance(I first, S last);
7
  ```
8
 
9
+ *Preconditions:* \[`first`, `last`) denotes a range.
 
 
10
 
11
+ *Effects:* Increments `first` until `last` is reached and returns the
12
+ number of increments.
13
+
14
+ ``` cpp
15
+ template<class I, sized_sentinel_for<decay_t<I>> S>
16
+ constexpr iter_difference_t<decay_t<I>> ranges::distance(I&& first, S last);
17
+ ```
18
+
19
+ *Effects:* Equivalent to:
20
+ `return last - static_cast<const decay_t<I>&>(first);`
21
 
22
  ``` cpp
23
  template<range R>
24
  constexpr range_difference_t<R> ranges::distance(R&& r);
25
  ```