tmp/tmpxzxjwnny/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#### Class template `slide_view` <a id="range.slide.view">[[range.slide.view]]</a>
|
| 2 |
+
|
| 3 |
+
``` cpp
|
| 4 |
+
namespace std::ranges {
|
| 5 |
+
template<class V>
|
| 6 |
+
concept slide-caches-nothing = random_access_range<V> && sized_range<V>; // exposition only
|
| 7 |
+
|
| 8 |
+
template<class V>
|
| 9 |
+
concept slide-caches-last = // exposition only
|
| 10 |
+
!slide-caches-nothing<V> && bidirectional_range<V> && common_range<V>;
|
| 11 |
+
|
| 12 |
+
template<class V>
|
| 13 |
+
concept slide-caches-first = // exposition only
|
| 14 |
+
!slide-caches-nothing<V> && !slide-caches-last<V>;
|
| 15 |
+
|
| 16 |
+
template<forward_range V>
|
| 17 |
+
requires view<V>
|
| 18 |
+
class slide_view : public view_interface<slide_view<V>> {
|
| 19 |
+
V base_; // exposition only
|
| 20 |
+
range_difference_t<V> n_; // exposition only
|
| 21 |
+
|
| 22 |
+
// [range.slide.iterator], class template slide_view::iterator
|
| 23 |
+
template<bool> class iterator; // exposition only
|
| 24 |
+
|
| 25 |
+
// [range.slide.sentinel], class slide_view::sentinel
|
| 26 |
+
class sentinel; // exposition only
|
| 27 |
+
|
| 28 |
+
public:
|
| 29 |
+
constexpr explicit slide_view(V base, range_difference_t<V> n);
|
| 30 |
+
|
| 31 |
+
constexpr V base() const & requires copy_constructible<V> { return base_; }
|
| 32 |
+
constexpr V base() && { return std::move(base_); }
|
| 33 |
+
|
| 34 |
+
constexpr auto begin()
|
| 35 |
+
requires (!(simple-view<V> && slide-caches-nothing<const V>));
|
| 36 |
+
constexpr auto begin() const requires slide-caches-nothing<const V>;
|
| 37 |
+
|
| 38 |
+
constexpr auto end()
|
| 39 |
+
requires (!(simple-view<V> && slide-caches-nothing<const V>));
|
| 40 |
+
constexpr auto end() const requires slide-caches-nothing<const V>;
|
| 41 |
+
|
| 42 |
+
constexpr auto size() requires sized_range<V>;
|
| 43 |
+
constexpr auto size() const requires sized_range<const V>;
|
| 44 |
+
};
|
| 45 |
+
|
| 46 |
+
template<class R>
|
| 47 |
+
slide_view(R&&, range_difference_t<R>) -> slide_view<views::all_t<R>>;
|
| 48 |
+
}
|
| 49 |
+
```
|
| 50 |
+
|
| 51 |
+
``` cpp
|
| 52 |
+
constexpr explicit slide_view(V base, range_difference_t<V> n);
|
| 53 |
+
```
|
| 54 |
+
|
| 55 |
+
*Preconditions:* `n > 0` is `true`.
|
| 56 |
+
|
| 57 |
+
*Effects:* Initializes *base\_* with `std::move(base)` and *n\_* with
|
| 58 |
+
`n`.
|
| 59 |
+
|
| 60 |
+
``` cpp
|
| 61 |
+
constexpr auto begin()
|
| 62 |
+
requires (!(simple-view<V> && slide-caches-nothing<const V>));
|
| 63 |
+
```
|
| 64 |
+
|
| 65 |
+
*Returns:*
|
| 66 |
+
|
| 67 |
+
- If `V` models `slide-caches-first`,
|
| 68 |
+
``` cpp
|
| 69 |
+
iterator<false>(ranges::begin(base_),
|
| 70 |
+
ranges::next(ranges::begin(base_), n_ - 1, ranges::end(base_)), n_)
|
| 71 |
+
```
|
| 72 |
+
- Otherwise,
|
| 73 |
+
*`iterator`*`<false>(ranges::begin(`*`base_`*`), `*`n_`*`)`.
|
| 74 |
+
|
| 75 |
+
*Remarks:* In order to provide the amortized constant-time complexity
|
| 76 |
+
required by the `range` concept, this function caches the result within
|
| 77 |
+
the `slide_view` for use on subsequent calls when `V` models
|
| 78 |
+
`slide-caches-first`.
|
| 79 |
+
|
| 80 |
+
``` cpp
|
| 81 |
+
constexpr auto begin() const requires slide-caches-nothing<const V>;
|
| 82 |
+
```
|
| 83 |
+
|
| 84 |
+
*Returns:* *`iterator`*`<true>(ranges::begin(`*`base_`*`), `*`n_`*`)`.
|
| 85 |
+
|
| 86 |
+
``` cpp
|
| 87 |
+
constexpr auto end()
|
| 88 |
+
requires (!(simple-view<V> && slide-caches-nothing<const V>));
|
| 89 |
+
```
|
| 90 |
+
|
| 91 |
+
*Returns:*
|
| 92 |
+
|
| 93 |
+
- If `V` models `slide-caches-nothing`,
|
| 94 |
+
``` cpp
|
| 95 |
+
iterator<false>(ranges::begin(base_) + range_difference_t<V>(size()), n_)
|
| 96 |
+
```
|
| 97 |
+
- Otherwise, if `V` models `slide-caches-last`,
|
| 98 |
+
``` cpp
|
| 99 |
+
iterator<false>(ranges::prev(ranges::end(base_), n_ - 1, ranges::begin(base_)), n_)
|
| 100 |
+
```
|
| 101 |
+
- Otherwise, if `V` models `common_range`,
|
| 102 |
+
``` cpp
|
| 103 |
+
iterator<false>(ranges::end(base_), ranges::end(base_), n_)
|
| 104 |
+
```
|
| 105 |
+
- Otherwise, *`sentinel`*`(ranges::end(`*`base_`*`))`.
|
| 106 |
+
|
| 107 |
+
*Remarks:* In order to provide the amortized constant-time complexity
|
| 108 |
+
required by the `range` concept, this function caches the result within
|
| 109 |
+
the `slide_view` for use on subsequent calls when `V` models
|
| 110 |
+
`slide-caches-last`.
|
| 111 |
+
|
| 112 |
+
``` cpp
|
| 113 |
+
constexpr auto end() const requires slide-caches-nothing<const V>;
|
| 114 |
+
```
|
| 115 |
+
|
| 116 |
+
*Returns:* `begin() + range_difference_t<const V>(size())`.
|
| 117 |
+
|
| 118 |
+
``` cpp
|
| 119 |
+
constexpr auto size() requires sized_range<V>;
|
| 120 |
+
constexpr auto size() const requires sized_range<const V>;
|
| 121 |
+
```
|
| 122 |
+
|
| 123 |
+
*Effects:* Equivalent to:
|
| 124 |
+
|
| 125 |
+
``` cpp
|
| 126 |
+
auto sz = ranges::distance(base_) - n_ + 1;
|
| 127 |
+
if (sz < 0) sz = 0;
|
| 128 |
+
return to-unsigned-like(sz);
|
| 129 |
+
```
|
| 130 |
+
|