tmp/tmpsb1k0nzi/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#### Class template `stride_view` <a id="range.stride.view">[[range.stride.view]]</a>
|
| 2 |
+
|
| 3 |
+
``` cpp
|
| 4 |
+
namespace std::ranges {
|
| 5 |
+
template<input_range V>
|
| 6 |
+
requires view<V>
|
| 7 |
+
class stride_view : public view_interface<stride_view<V>> {
|
| 8 |
+
V base_; // exposition only
|
| 9 |
+
range_difference_t<V> stride_; // exposition only
|
| 10 |
+
// [range.stride.iterator], class template stride_view::iterator
|
| 11 |
+
template<bool> class iterator; // exposition only
|
| 12 |
+
public:
|
| 13 |
+
constexpr explicit stride_view(V base, range_difference_t<V> stride);
|
| 14 |
+
|
| 15 |
+
constexpr V base() const & requires copy_constructible<V> { return base_; }
|
| 16 |
+
constexpr V base() && { return std::move(base_); }
|
| 17 |
+
|
| 18 |
+
constexpr range_difference_t<V> stride() const noexcept;
|
| 19 |
+
|
| 20 |
+
constexpr auto begin() requires (!simple-view<V>) {
|
| 21 |
+
return iterator<false>(this, ranges::begin(base_));
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
constexpr auto begin() const requires range<const V> {
|
| 25 |
+
return iterator<true>(this, ranges::begin(base_));
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
constexpr auto end() requires (!simple-view<V>) {
|
| 29 |
+
if constexpr (common_range<V> && sized_range<V> && forward_range<V>) {
|
| 30 |
+
auto missing = (stride_ - ranges::distance(base_) % stride_) % stride_;
|
| 31 |
+
return iterator<false>(this, ranges::end(base_), missing);
|
| 32 |
+
} else if constexpr (common_range<V> && !bidirectional_range<V>) {
|
| 33 |
+
return iterator<false>(this, ranges::end(base_));
|
| 34 |
+
} else {
|
| 35 |
+
return default_sentinel;
|
| 36 |
+
}
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
constexpr auto end() const requires range<const V> {
|
| 40 |
+
if constexpr (common_range<const V> && sized_range<const V> && forward_range<const V>) {
|
| 41 |
+
auto missing = (stride_ - ranges::distance(base_) % stride_) % stride_;
|
| 42 |
+
return iterator<true>(this, ranges::end(base_), missing);
|
| 43 |
+
} else if constexpr (common_range<const V> && !bidirectional_range<const V>) {
|
| 44 |
+
return iterator<true>(this, ranges::end(base_));
|
| 45 |
+
} else {
|
| 46 |
+
return default_sentinel;
|
| 47 |
+
}
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
constexpr auto size() requires sized_range<V>;
|
| 51 |
+
constexpr auto size() const requires sized_range<const V>;
|
| 52 |
+
};
|
| 53 |
+
|
| 54 |
+
template<class R>
|
| 55 |
+
stride_view(R&&, range_difference_t<R>) -> stride_view<views::all_t<R>>;
|
| 56 |
+
}
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
``` cpp
|
| 60 |
+
constexpr stride_view(V base, range_difference_t<V> stride);
|
| 61 |
+
```
|
| 62 |
+
|
| 63 |
+
*Preconditions:* `stride > 0` is `true`.
|
| 64 |
+
|
| 65 |
+
*Effects:* Initializes *base\_* with `std::move(base)` and *stride\_*
|
| 66 |
+
with `stride`.
|
| 67 |
+
|
| 68 |
+
``` cpp
|
| 69 |
+
constexpr range_difference_t<V> stride() const noexcept;
|
| 70 |
+
```
|
| 71 |
+
|
| 72 |
+
*Returns:* *stride\_*.
|
| 73 |
+
|
| 74 |
+
``` cpp
|
| 75 |
+
constexpr auto size() requires sized_range<V>;
|
| 76 |
+
constexpr auto size() const requires sized_range<const V>;
|
| 77 |
+
```
|
| 78 |
+
|
| 79 |
+
*Effects:* Equivalent to:
|
| 80 |
+
|
| 81 |
+
``` cpp
|
| 82 |
+
return to-unsigned-like(div-ceil(ranges::distance(base_), stride_));
|
| 83 |
+
```
|
| 84 |
+
|