From Jason Turner

[range.lazy.split.inner]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpivt6f10y/{from.md → to.md} +145 -0
tmp/tmpivt6f10y/{from.md → to.md} RENAMED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### Class template `lazy_split_view::inner-iterator` <a id="range.lazy.split.inner">[[range.lazy.split.inner]]</a>
2
+
3
+ ``` cpp
4
+ namespace std::ranges {
5
+ template<input_range V, forward_range Pattern>
6
+ requires view<V> && view<Pattern> &&
7
+ indirectly_comparable<iterator_t<V>, iterator_t<Pattern>, ranges::equal_to> &&
8
+ (forward_range<V> || tiny-range<Pattern>)
9
+ template<bool Const>
10
+ struct lazy_split_view<V, Pattern>::inner-iterator {
11
+ private:
12
+ using Base = maybe-const<Const, V>; // exposition only
13
+ outer-iterator<Const> i_ = outer-iterator<Const>(); // exposition only
14
+ bool incremented_ = false; // exposition only
15
+
16
+ public:
17
+ using iterator_concept = typename outer-iterator<Const>::iterator_concept;
18
+
19
+ using iterator_category = see belownc; // present only if Base
20
+ // models forward_range
21
+ using value_type = range_value_t<Base>;
22
+ using difference_type = range_difference_t<Base>;
23
+
24
+ inner-iterator() = default;
25
+ constexpr explicit inner-iterator(outer-iterator<Const> i);
26
+
27
+ constexpr const iterator_t<Base>& base() const & noexcept;
28
+ constexpr iterator_t<Base> base() && requires forward_range<V>;
29
+
30
+ constexpr decltype(auto) operator*() const { return *i_.current; }
31
+
32
+ constexpr inner-iterator& operator++();
33
+ constexpr decltype(auto) operator++(int) {
34
+ if constexpr (forward_range<Base>) {
35
+ auto tmp = *this;
36
+ ++*this;
37
+ return tmp;
38
+ } else
39
+ ++*this;
40
+ }
41
+
42
+ friend constexpr bool operator==(const inner-iterator& x, const inner-iterator& y)
43
+ requires forward_range<Base>;
44
+
45
+ friend constexpr bool operator==(const inner-iterator& x, default_sentinel_t);
46
+
47
+ friend constexpr decltype(auto) iter_move(const inner-iterator& i)
48
+ noexcept(noexcept(ranges::iter_move(i.i_.current))) {
49
+ return ranges::iter_move(i.i_.current);
50
+ }
51
+
52
+ friend constexpr void iter_swap(const inner-iterator& x, const inner-iterator& y)
53
+ noexcept(noexcept(ranges::iter_swap(x.i_.current, y.i_.current)))
54
+ requires indirectly_swappable<iterator_t<Base>>;
55
+ };
56
+ }
57
+ ```
58
+
59
+ If *`Base`* does not model `forward_range` there is no member
60
+ `iterator_category`. Otherwise, the *typedef-name* `iterator_category`
61
+ denotes:
62
+
63
+ - `forward_iterator_tag` if
64
+ `iterator_traits<iterator_t<Base>>::iterator_category` models
65
+ `derived_from<forward_iterator_tag>`;
66
+ - otherwise, `iterator_traits<iterator_t<Base>>::iterator_category`.
67
+
68
+ ``` cpp
69
+ constexpr explicit inner-iterator(outer-iterator<Const> i);
70
+ ```
71
+
72
+ *Effects:* Initializes *i\_* with `std::move(i)`.
73
+
74
+ ``` cpp
75
+ constexpr const iterator_t<Base>& base() const & noexcept;
76
+ ```
77
+
78
+ *Effects:* Equivalent to: `return `*`i_`*`.`*`current`*`;`
79
+
80
+ ``` cpp
81
+ constexpr iterator_t<Base> base() && requires forward_range<V>;
82
+ ```
83
+
84
+ *Effects:* Equivalent to: `return std::move(`*`i_`*`.`*`current`*`);`
85
+
86
+ ``` cpp
87
+ constexpr inner-iterator& operator++();
88
+ ```
89
+
90
+ *Effects:* Equivalent to:
91
+
92
+ ``` cpp
93
+ incremented_ = true;
94
+ if constexpr (!forward_range<Base>) {
95
+ if constexpr (Pattern::size() == 0) {
96
+ return *this;
97
+ }
98
+ }
99
+ ++i_.current;
100
+ return *this;
101
+ ```
102
+
103
+ ``` cpp
104
+ friend constexpr bool operator==(const inner-iterator& x, const inner-iterator& y)
105
+ requires forward_range<Base>;
106
+ ```
107
+
108
+ *Effects:* Equivalent to:
109
+ `return x.`*`i_`*`.`*`current`*` == y.`*`i_`*`.`*`current`*`;`
110
+
111
+ ``` cpp
112
+ friend constexpr bool operator==(const inner-iterator& x, default_sentinel_t);
113
+ ```
114
+
115
+ *Effects:* Equivalent to:
116
+
117
+ ``` cpp
118
+ auto [pcur, pend] = subrange{x.i_.parent_->pattern_};
119
+ auto end = ranges::end(x.i_.parent_->base_);
120
+ if constexpr (tiny-range<Pattern>) {
121
+ const auto & cur = x.i_.current;
122
+ if (cur == end) return true;
123
+ if (pcur == pend) return x.incremented_;
124
+ return *cur == *pcur;
125
+ } else {
126
+ auto cur = x.i_.current;
127
+ if (cur == end) return true;
128
+ if (pcur == pend) return x.incremented_;
129
+ do {
130
+ if (*cur != *pcur) return false;
131
+ if (++pcur == pend) return true;
132
+ } while (++cur != end);
133
+ return false;
134
+ }
135
+ ```
136
+
137
+ ``` cpp
138
+ friend constexpr void iter_swap(const inner-iterator& x, const inner-iterator& y)
139
+ noexcept(noexcept(ranges::iter_swap(x.i_.current, y.i_.current)))
140
+ requires indirectly_swappable<iterator_t<Base>>;
141
+ ```
142
+
143
+ *Effects:* Equivalent to
144
+ `ranges::iter_swap(x.`*`i_`*`.`*`current`*`, y.`*`i_`*`.`*`current`*`)`.
145
+