From Jason Turner

[range.chunk.view.input]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpkzea2va1/{from.md → to.md} +83 -0
tmp/tmpkzea2va1/{from.md → to.md} RENAMED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### Class template `chunk_view` for input ranges <a id="range.chunk.view.input">[[range.chunk.view.input]]</a>
2
+
3
+ ``` cpp
4
+ namespace std::ranges {
5
+ template<class I>
6
+ constexpr I div-ceil(I num, I denom) { // exposition only
7
+ I r = num / denom;
8
+ if (num % denom)
9
+ ++r;
10
+ return r;
11
+ }
12
+
13
+ template<view V>
14
+ requires input_range<V>
15
+ class chunk_view : public view_interface<chunk_view<V>> {
16
+ V base_; // exposition only
17
+ range_difference_t<V> n_; // exposition only
18
+ range_difference_t<V> remainder_ = 0; // exposition only
19
+
20
+ non-propagating-cache<iterator_t<V>> current_; // exposition only
21
+
22
+ // [range.chunk.outer.iter], class chunk_view::outer-iterator
23
+ class outer-iterator; // exposition only
24
+
25
+ // [range.chunk.inner.iter], class chunk_view::inner-iterator
26
+ class inner-iterator; // exposition only
27
+
28
+ public:
29
+ constexpr explicit chunk_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 outer-iterator begin();
35
+ constexpr default_sentinel_t end() const noexcept;
36
+
37
+ constexpr auto size() requires sized_range<V>;
38
+ constexpr auto size() const requires sized_range<const V>;
39
+ };
40
+
41
+ template<class R>
42
+ chunk_view(R&&, range_difference_t<R>) -> chunk_view<views::all_t<R>>;
43
+ }
44
+ ```
45
+
46
+ ``` cpp
47
+ constexpr explicit chunk_view(V base, range_difference_t<V> n);
48
+ ```
49
+
50
+ *Preconditions:* `n > 0` is `true`.
51
+
52
+ *Effects:* Initializes *base\_* with `std::move(base)` and *n\_* with
53
+ `n`.
54
+
55
+ ``` cpp
56
+ constexpr outer-iterator begin();
57
+ ```
58
+
59
+ *Effects:* Equivalent to:
60
+
61
+ ``` cpp
62
+ current_ = ranges::begin(base_);
63
+ remainder_ = n_;
64
+ return outer-iterator(*this);
65
+ ```
66
+
67
+ ``` cpp
68
+ constexpr default_sentinel_t end() const noexcept;
69
+ ```
70
+
71
+ *Returns:* `default_sentinel`.
72
+
73
+ ``` cpp
74
+ constexpr auto size() requires sized_range<V>;
75
+ constexpr auto size() const requires sized_range<const V>;
76
+ ```
77
+
78
+ *Effects:* Equivalent to:
79
+
80
+ ``` cpp
81
+ return to-unsigned-like(div-ceil(ranges::distance(base_), n_));
82
+ ```
83
+