From Jason Turner

[range.drop.view]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpd8h8gaaq/{from.md → to.md} +78 -0
tmp/tmpd8h8gaaq/{from.md → to.md} RENAMED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### Class template `drop_view` <a id="range.drop.view">[[range.drop.view]]</a>
2
+
3
+ ``` cpp
4
+ namespace std::ranges {
5
+ template<view V>
6
+ class drop_view : public view_interface<drop_view<V>> {
7
+ public:
8
+ drop_view() = default;
9
+ constexpr drop_view(V base, range_difference_t<V> count);
10
+
11
+ constexpr V base() const& requires copy_constructible<V> { return base_; }
12
+ constexpr V base() && { return std::move(base_); }
13
+
14
+ constexpr auto begin()
15
+ requires (!(simple-view<V> && random_access_range<V>));
16
+ constexpr auto begin() const
17
+ requires random_access_range<const V>;
18
+
19
+ constexpr auto end()
20
+ requires (!simple-view<V>)
21
+ { return ranges::end(base_); }
22
+
23
+ constexpr auto end() const
24
+ requires range<const V>
25
+ { return ranges::end(base_); }
26
+
27
+ constexpr auto size()
28
+ requires sized_range<V>
29
+ {
30
+ const auto s = ranges::size(base_);
31
+ const auto c = static_cast<decltype(s)>(count_);
32
+ return s < c ? 0 : s - c;
33
+ }
34
+
35
+ constexpr auto size() const
36
+ requires sized_range<const V>
37
+ {
38
+ const auto s = ranges::size(base_);
39
+ const auto c = static_cast<decltype(s)>(count_);
40
+ return s < c ? 0 : s - c;
41
+ }
42
+ private:
43
+ V base_ = V(); // exposition only
44
+ range_difference_t<V> count_ = 0; // exposition only
45
+ };
46
+
47
+ template<class R>
48
+ drop_view(R&&, range_difference_t<R>) -> drop_view<views::all_t<R>>;
49
+ }
50
+ ```
51
+
52
+ ``` cpp
53
+ constexpr drop_view(V base, range_difference_t<V> count);
54
+ ```
55
+
56
+ *Preconditions:* `count >= 0` is `true`.
57
+
58
+ *Effects:* Initializes *base\_* with `std::move(base)` and *count\_*
59
+ with `count`.
60
+
61
+ ``` cpp
62
+ constexpr auto begin()
63
+ requires (!(simple-view<V> && random_access_range<V>));
64
+ constexpr auto begin() const
65
+ requires random_access_range<const V>;
66
+ ```
67
+
68
+ *Returns:*
69
+ `ranges::next(ranges::begin(base_), count_, ranges::end(base_))`.
70
+
71
+ *Remarks:* In order to provide the amortized constant-time complexity
72
+ required by the `range` concept when `drop_view` models `forward_range`,
73
+ the first overload caches the result within the `drop_view` for use on
74
+ subsequent calls.
75
+
76
+ [*Note 1*: Without this, applying a `reverse_view` over a `drop_view`
77
+ would have quadratic iteration complexity. — *end note*]
78
+