From Jason Turner

[range.chunk.fwd.iter]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpc_e70_w0/{from.md → to.md} +307 -0
tmp/tmpc_e70_w0/{from.md → to.md} RENAMED
@@ -0,0 +1,307 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### Class template `chunk_view::iterator` for forward ranges <a id="range.chunk.fwd.iter">[[range.chunk.fwd.iter]]</a>
2
+
3
+ ``` cpp
4
+ namespace std::ranges {
5
+ template<view V>
6
+ requires forward_range<V>
7
+ template<bool Const>
8
+ class chunk_view<V>::iterator {
9
+ using Parent = maybe-const<Const, chunk_view>; // exposition only
10
+ using Base = maybe-const<Const, V>; // exposition only
11
+
12
+ iterator_t<Base> current_ = iterator_t<Base>(); // exposition only
13
+ sentinel_t<Base> end_ = sentinel_t<Base>(); // exposition only
14
+ range_difference_t<Base> n_ = 0; // exposition only
15
+ range_difference_t<Base> missing_ = 0; // exposition only
16
+
17
+ constexpr iterator(Parent* parent, iterator_t<Base> current, // exposition only
18
+ range_difference_t<Base> missing = 0);
19
+
20
+ public:
21
+ using iterator_category = input_iterator_tag;
22
+ using iterator_concept = see below;
23
+ using value_type = decltype(views::take(subrange(current_, end_), n_));
24
+ using difference_type = range_difference_t<Base>;
25
+
26
+ iterator() = default;
27
+ constexpr iterator(iterator<!Const> i)
28
+ requires Const && convertible_to<iterator_t<V>, iterator_t<Base>>
29
+ && convertible_to<sentinel_t<V>, sentinel_t<Base>>;
30
+
31
+ constexpr iterator_t<Base> base() const;
32
+
33
+ constexpr value_type operator*() const;
34
+ constexpr iterator& operator++();
35
+ constexpr iterator operator++(int);
36
+
37
+ constexpr iterator& operator--() requires bidirectional_range<Base>;
38
+ constexpr iterator operator--(int) requires bidirectional_range<Base>;
39
+
40
+ constexpr iterator& operator+=(difference_type x)
41
+ requires random_access_range<Base>;
42
+ constexpr iterator& operator-=(difference_type x)
43
+ requires random_access_range<Base>;
44
+
45
+ constexpr value_type operator[](difference_type n) const
46
+ requires random_access_range<Base>;
47
+
48
+ friend constexpr bool operator==(const iterator& x, const iterator& y);
49
+ friend constexpr bool operator==(const iterator& x, default_sentinel_t);
50
+
51
+ friend constexpr bool operator<(const iterator& x, const iterator& y)
52
+ requires random_access_range<Base>;
53
+ friend constexpr bool operator>(const iterator& x, const iterator& y)
54
+ requires random_access_range<Base>;
55
+ friend constexpr bool operator<=(const iterator& x, const iterator& y)
56
+ requires random_access_range<Base>;
57
+ friend constexpr bool operator>=(const iterator& x, const iterator& y)
58
+ requires random_access_range<Base>;
59
+ friend constexpr auto operator<=>(const iterator& x, const iterator& y)
60
+ requires random_access_range<Base> &&
61
+ three_way_comparable<iterator_t<Base>>;
62
+
63
+ friend constexpr iterator operator+(const iterator& i, difference_type n)
64
+ requires random_access_range<Base>;
65
+ friend constexpr iterator operator+(difference_type n, const iterator& i)
66
+ requires random_access_range<Base>;
67
+ friend constexpr iterator operator-(const iterator& i, difference_type n)
68
+ requires random_access_range<Base>;
69
+ friend constexpr difference_type operator-(const iterator& x, const iterator& y)
70
+ requires sized_sentinel_for<iterator_t<Base>, iterator_t<Base>>;
71
+
72
+ friend constexpr difference_type operator-(default_sentinel_t y, const iterator& x)
73
+ requires sized_sentinel_for<sentinel_t<Base>, iterator_t<Base>>;
74
+ friend constexpr difference_type operator-(const iterator& x, default_sentinel_t y)
75
+ requires sized_sentinel_for<sentinel_t<Base>, iterator_t<Base>>;
76
+ };
77
+ }
78
+ ```
79
+
80
+ `iterator::iterator_concept` is defined as follows:
81
+
82
+ - If *`Base`* models `random_access_range`, then `iterator_concept`
83
+ denotes `random_access_iterator_tag`.
84
+ - Otherwise, if *`Base`* models `bidirectional_range`, then
85
+ `iterator_concept` denotes `bidirectional_iterator_tag`.
86
+ - Otherwise, `iterator_concept` denotes `forward_iterator_tag`.
87
+
88
+ ``` cpp
89
+ constexpr iterator(Parent* parent, iterator_t<Base> current,
90
+ range_difference_t<Base> missing = 0);
91
+ ```
92
+
93
+ *Effects:* Initializes *current\_* with `current`, *end\_* with
94
+ `ranges::end(parent->`*`base_`*`)`, *n\_* with `parent->`*`n_`*, and
95
+ *missing\_* with `missing`.
96
+
97
+ ``` cpp
98
+ constexpr iterator(iterator<!Const> i)
99
+ requires Const && convertible_to<iterator_t<V>, iterator_t<Base>>
100
+ && convertible_to<sentinel_t<V>, sentinel_t<Base>>;
101
+ ```
102
+
103
+ *Effects:* Initializes *current\_* with `std::move(i.`*`current_`*`)`,
104
+ *end\_* with `std::move(i.`*`end_`*`)`, *n\_* with `i.`*`n_`*, and
105
+ *missing\_* with `i.`*`missing_`*.
106
+
107
+ ``` cpp
108
+ constexpr iterator_t<Base> base() const;
109
+ ```
110
+
111
+ *Returns:* *current\_*.
112
+
113
+ ``` cpp
114
+ constexpr value_type operator*() const;
115
+ ```
116
+
117
+ *Preconditions:* *`current_`*` != `*`end_`* is `true`.
118
+
119
+ *Returns:*
120
+ `views::take(subrange(`*`current_`*`, `*`end_`*`), `*`n_`*`)`.
121
+
122
+ ``` cpp
123
+ constexpr iterator& operator++();
124
+ ```
125
+
126
+ *Preconditions:* *`current_`*` != `*`end_`* is `true`.
127
+
128
+ *Effects:* Equivalent to:
129
+
130
+ ``` cpp
131
+ missing_ = ranges::advance(current_, n_, end_);
132
+ return *this;
133
+ ```
134
+
135
+ ``` cpp
136
+ constexpr iterator operator++(int);
137
+ ```
138
+
139
+ *Effects:* Equivalent to:
140
+
141
+ ``` cpp
142
+ auto tmp = *this;
143
+ ++*this;
144
+ return tmp;
145
+ ```
146
+
147
+ ``` cpp
148
+ constexpr iterator& operator--() requires bidirectional_range<Base>;
149
+ ```
150
+
151
+ *Effects:* Equivalent to:
152
+
153
+ ``` cpp
154
+ ranges::advance(current_, missing_ - n_);
155
+ missing_ = 0;
156
+ return *this;
157
+ ```
158
+
159
+ ``` cpp
160
+ constexpr iterator operator--(int) requires bidirectional_range<Base>;
161
+ ```
162
+
163
+ *Effects:* Equivalent to:
164
+
165
+ ``` cpp
166
+ auto tmp = *this;
167
+ --*this;
168
+ return tmp;
169
+ ```
170
+
171
+ ``` cpp
172
+ constexpr iterator& operator+=(difference_type x)
173
+ requires random_access_range<Base>;
174
+ ```
175
+
176
+ *Preconditions:* If `x` is positive,
177
+ `ranges::distance(`*`current_`*`, `*`end_`*`) > `*`n_`*` * (x - 1)` is
178
+ `true`.
179
+
180
+ [*Note 1*: If `x` is negative, the *Effects* paragraph implies a
181
+ precondition. — *end note*]
182
+
183
+ *Effects:* Equivalent to:
184
+
185
+ ``` cpp
186
+ if (x > 0) {
187
+ ranges::advance(current_, n_ * (x - 1));
188
+ missing_ = ranges::advance(current_, n_, end_);
189
+ } else if (x < 0) {
190
+ ranges::advance(current_, n_ * x + missing_);
191
+ missing_ = 0;
192
+ }
193
+ return *this;
194
+ ```
195
+
196
+ ``` cpp
197
+ constexpr iterator& operator-=(difference_type x)
198
+ requires random_access_range<Base>;
199
+ ```
200
+
201
+ *Effects:* Equivalent to: `return *this += -x;`
202
+
203
+ ``` cpp
204
+ constexpr value_type operator[](difference_type n) const
205
+ requires random_access_range<Base>;
206
+ ```
207
+
208
+ *Returns:* `*(*this + n)`.
209
+
210
+ ``` cpp
211
+ friend constexpr bool operator==(const iterator& x, const iterator& y);
212
+ ```
213
+
214
+ *Returns:* `x.`*`current_`*` == y.`*`current_`*.
215
+
216
+ ``` cpp
217
+ friend constexpr bool operator==(const iterator& x, default_sentinel_t);
218
+ ```
219
+
220
+ *Returns:* `x.`*`current_`*` == x.`*`end_`*.
221
+
222
+ ``` cpp
223
+ friend constexpr bool operator<(const iterator& x, const iterator& y)
224
+ requires random_access_range<Base>;
225
+ ```
226
+
227
+ *Returns:* `x.`*`current_`*` < y.`*`current_`*.
228
+
229
+ ``` cpp
230
+ friend constexpr bool operator>(const iterator& x, const iterator& y)
231
+ requires random_access_range<Base>;
232
+ ```
233
+
234
+ *Effects:* Equivalent to: `return y < x;`
235
+
236
+ ``` cpp
237
+ friend constexpr bool operator<=(const iterator& x, const iterator& y)
238
+ requires random_access_range<Base>;
239
+ ```
240
+
241
+ *Effects:* Equivalent to: `return !(y < x);`
242
+
243
+ ``` cpp
244
+ friend constexpr bool operator>=(const iterator& x, const iterator& y)
245
+ requires random_access_range<Base>;
246
+ ```
247
+
248
+ *Effects:* Equivalent to: `return !(x < y);`
249
+
250
+ ``` cpp
251
+ friend constexpr auto operator<=>(const iterator& x, const iterator& y)
252
+ requires random_access_range<Base> &&
253
+ three_way_comparable<iterator_t<Base>>;
254
+ ```
255
+
256
+ *Returns:* `x.`*`current_`*` <=> y.`*`current_`*.
257
+
258
+ ``` cpp
259
+ friend constexpr iterator operator+(const iterator& i, difference_type n)
260
+ requires random_access_range<Base>;
261
+ friend constexpr iterator operator+(difference_type n, const iterator& i)
262
+ requires random_access_range<Base>;
263
+ ```
264
+
265
+ *Effects:* Equivalent to:
266
+
267
+ ``` cpp
268
+ auto r = i;
269
+ r += n;
270
+ return r;
271
+ ```
272
+
273
+ ``` cpp
274
+ friend constexpr iterator operator-(const iterator& i, difference_type n)
275
+ requires random_access_range<Base>;
276
+ ```
277
+
278
+ *Effects:* Equivalent to:
279
+
280
+ ``` cpp
281
+ auto r = i;
282
+ r -= n;
283
+ return r;
284
+ ```
285
+
286
+ ``` cpp
287
+ friend constexpr difference_type operator-(const iterator& x, const iterator& y)
288
+ requires sized_sentinel_for<iterator_t<Base>, iterator_t<Base>>;
289
+ ```
290
+
291
+ *Returns:*
292
+ `(x.`*`current_`*` - y.`*`current_`*` + x.`*`missing_`*` - y.`*`missing_`*`) / x.`*`n_`*.
293
+
294
+ ``` cpp
295
+ friend constexpr difference_type operator-(default_sentinel_t y, const iterator& x)
296
+ requires sized_sentinel_for<sentinel_t<Base>, iterator_t<Base>>;
297
+ ```
298
+
299
+ *Returns:* *`div-ceil`*`(x.`*`end_`*` - x.`*`current_`*`, x.`*`n_`*`)`.
300
+
301
+ ``` cpp
302
+ friend constexpr difference_type operator-(const iterator& x, default_sentinel_t y)
303
+ requires sized_sentinel_for<sentinel_t<Base>, iterator_t<Base>>;
304
+ ```
305
+
306
+ *Effects:* Equivalent to: `return -(y - x);`
307
+