From Jason Turner

[range.chunk.by.view]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpyzd5vogd/{from.md → to.md} +105 -0
tmp/tmpyzd5vogd/{from.md → to.md} RENAMED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### Class template `chunk_by_view` <a id="range.chunk.by.view">[[range.chunk.by.view]]</a>
2
+
3
+ ``` cpp
4
+ namespace std::ranges {
5
+ template<forward_range V, indirect_binary_predicate<iterator_t<V>, iterator_t<V>> Pred>
6
+ requires view<V> && is_object_v<Pred>
7
+ class chunk_by_view : public view_interface<chunk_by_view<V, Pred>> {
8
+ V base_ = V(); // exposition only
9
+ movable-box<Pred> pred_; // exposition only
10
+
11
+ // [range.chunk.by.iter], class chunk_by_view::iterator
12
+ class iterator; // exposition only
13
+
14
+ public:
15
+ chunk_by_view() requires default_initializable<V> && default_initializable<Pred> = default;
16
+ constexpr explicit chunk_by_view(V base, Pred pred);
17
+
18
+ constexpr V base() const & requires copy_constructible<V> { return base_; }
19
+ constexpr V base() && { return std::move(base_); }
20
+
21
+ constexpr const Pred& pred() const;
22
+
23
+ constexpr iterator begin();
24
+ constexpr auto end();
25
+
26
+ constexpr iterator_t<V> find-next(iterator_t<V>); // exposition only
27
+ constexpr iterator_t<V> find-prev(iterator_t<V>) // exposition only
28
+ requires bidirectional_range<V>;
29
+ };
30
+
31
+ template<class R, class Pred>
32
+ chunk_by_view(R&&, Pred) -> chunk_by_view<views::all_t<R>, Pred>;
33
+ }
34
+ ```
35
+
36
+ ``` cpp
37
+ constexpr explicit chunk_by_view(V base, Pred pred);
38
+ ```
39
+
40
+ *Effects:* Initializes *base\_* with `std::move(base)` and *pred\_* with
41
+ `std::move(pred)`.
42
+
43
+ ``` cpp
44
+ constexpr const Pred& pred() const;
45
+ ```
46
+
47
+ *Effects:* Equivalent to: `return *`*`pred_`*`;`
48
+
49
+ ``` cpp
50
+ constexpr iterator begin();
51
+ ```
52
+
53
+ *Preconditions:* *`pred_`*`.has_value()` is `true`.
54
+
55
+ *Returns:*
56
+ *`iterator`*`(*this, ranges::begin(`*`base_`*`), `*`find-next`*`(ranges::begin(`*`base_`*`)))`.
57
+
58
+ *Remarks:* In order to provide the amortized constant-time complexity
59
+ required by the `range` concept, this function caches the result within
60
+ the `chunk_by_view` for use on subsequent calls.
61
+
62
+ ``` cpp
63
+ constexpr auto end();
64
+ ```
65
+
66
+ *Effects:* Equivalent to:
67
+
68
+ ``` cpp
69
+ if constexpr (common_range<V>) {
70
+ return iterator(*this, ranges::end(base_), ranges::end(base_));
71
+ } else {
72
+ return default_sentinel;
73
+ }
74
+ ```
75
+
76
+ ``` cpp
77
+ constexpr iterator_t<V> find-next(iterator_t<V> current);
78
+ ```
79
+
80
+ *Preconditions:* *`pred_`*`.has_value()` is `true`.
81
+
82
+ *Returns:*
83
+
84
+ ``` cpp
85
+ ranges::next(ranges::adjacent_find(current, ranges::end(base_), not_fn(ref(*pred_))),
86
+ 1, ranges::end(base_))
87
+ ```
88
+
89
+ ``` cpp
90
+ constexpr iterator_t<V> find-prev(iterator_t<V> current) requires bidirectional_range<V>;
91
+ ```
92
+
93
+ *Preconditions:*
94
+
95
+ - `current` is not equal to `ranges::begin(`*`base_`*`)`.
96
+ - *`pred_`*`.has_value()` is `true`.
97
+
98
+ *Returns:* An iterator `i` in the range \[`ranges::begin(`*`base_`*`)`,
99
+ `current`) such that:
100
+
101
+ - `ranges::adjacent_find(i, current, not_fn(ref(*`*`pred_`*`)))` is
102
+ equal to `current`; and
103
+ - if `i` is not equal to `ranges::begin(`*`base_`*`)`, then
104
+ `bool(invoke(*`*`pred_`*`, *ranges::prev(i), *i))` is `false`.
105
+