From Jason Turner

[range.zip.iterator]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpetmmoeox/{from.md → to.md} +301 -0
tmp/tmpetmmoeox/{from.md → to.md} RENAMED
@@ -0,0 +1,301 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### Class template `zip_view::iterator` <a id="range.zip.iterator">[[range.zip.iterator]]</a>
2
+
3
+ ``` cpp
4
+ namespace std::ranges {
5
+ template<bool Const, class... Views>
6
+ concept all-random-access = // exposition only
7
+ (random_access_range<maybe-const<Const, Views>> && ...);
8
+ template<bool Const, class... Views>
9
+ concept all-bidirectional = // exposition only
10
+ (bidirectional_range<maybe-const<Const, Views>> && ...);
11
+ template<bool Const, class... Views>
12
+ concept all-forward = // exposition only
13
+ (forward_range<maybe-const<Const, Views>> && ...);
14
+
15
+ template<input_range... Views>
16
+ requires (view<Views> && ...) && (sizeof...(Views) > 0)
17
+ template<bool Const>
18
+ class zip_view<Views...>::iterator {
19
+ tuple<iterator_t<maybe-const<Const, Views>>...> current_; // exposition only
20
+ constexpr explicit iterator(tuple<iterator_t<maybe-const<Const, Views>>...>);
21
+ // exposition only
22
+ public:
23
+ using iterator_category = input_iterator_tag; // not always present
24
+ using iterator_concept = see below;
25
+ using value_type = tuple<range_value_t<maybe-const<Const, Views>>...>;
26
+ using difference_type = common_type_t<range_difference_t<maybe-const<Const, Views>>...>;
27
+
28
+ iterator() = default;
29
+ constexpr iterator(iterator<!Const> i)
30
+ requires Const && (convertible_to<iterator_t<Views>, iterator_t<const Views>> && ...);
31
+
32
+ constexpr auto operator*() const;
33
+ constexpr iterator& operator++();
34
+ constexpr void operator++(int);
35
+ constexpr iterator operator++(int) requires all-forward<Const, Views...>;
36
+
37
+ constexpr iterator& operator--() requires all-bidirectional<Const, Views...>;
38
+ constexpr iterator operator--(int) requires all-bidirectional<Const, Views...>;
39
+
40
+ constexpr iterator& operator+=(difference_type x)
41
+ requires all-random-access<Const, Views...>;
42
+ constexpr iterator& operator-=(difference_type x)
43
+ requires all-random-access<Const, Views...>;
44
+
45
+ constexpr auto operator[](difference_type n) const
46
+ requires all-random-access<Const, Views...>;
47
+
48
+ friend constexpr bool operator==(const iterator& x, const iterator& y)
49
+ requires (equality_comparable<iterator_t<maybe-const<Const, Views>>> && ...);
50
+
51
+ friend constexpr auto operator<=>(const iterator& x, const iterator& y)
52
+ requires all-random-access<Const, Views...>;
53
+
54
+ friend constexpr iterator operator+(const iterator& i, difference_type n)
55
+ requires all-random-access<Const, Views...>;
56
+ friend constexpr iterator operator+(difference_type n, const iterator& i)
57
+ requires all-random-access<Const, Views...>;
58
+ friend constexpr iterator operator-(const iterator& i, difference_type n)
59
+ requires all-random-access<Const, Views...>;
60
+ friend constexpr difference_type operator-(const iterator& x, const iterator& y)
61
+ requires (sized_sentinel_for<iterator_t<maybe-const<Const, Views>>,
62
+ iterator_t<maybe-const<Const, Views>>> && ...);
63
+
64
+ friend constexpr auto iter_move(const iterator& i) noexcept(see below);
65
+
66
+ friend constexpr void iter_swap(const iterator& l, const iterator& r) noexcept(see below)
67
+ requires (indirectly_swappable<iterator_t<maybe-const<Const, Views>>> && ...);
68
+ };
69
+ }
70
+ ```
71
+
72
+ `iterator::iterator_concept` is defined as follows:
73
+
74
+ - If `all-random-access<Const, Views...>` is modeled, then
75
+ `iterator_concept` denotes `random_access_iterator_tag`.
76
+ - Otherwise, if `all-bidirectional<Const, Views...>` is modeled, then
77
+ `iterator_concept` denotes `bidirectional_iterator_tag`.
78
+ - Otherwise, if `all-forward<Const, Views...>` is modeled, then
79
+ `iterator_concept` denotes `forward_iterator_tag`.
80
+ - Otherwise, `iterator_concept` denotes `input_iterator_tag`.
81
+
82
+ `iterator::iterator_category` is present if and only if
83
+ `all-forward<Const, Views...>` is modeled.
84
+
85
+ If the invocation of any non-const member function of *`iterator`* exits
86
+ via an exception, the iterator acquires a singular value.
87
+
88
+ ``` cpp
89
+ constexpr explicit iterator(tuple<iterator_t<maybe-const<Const, Views>>...> current);
90
+ ```
91
+
92
+ *Effects:* Initializes *current\_* with `std::move(current)`.
93
+
94
+ ``` cpp
95
+ constexpr iterator(iterator<!Const> i)
96
+ requires Const && (convertible_to<iterator_t<Views>, iterator_t<const Views>> && ...);
97
+ ```
98
+
99
+ *Effects:* Initializes *current\_* with `std::move(i.`*`current_`*`)`.
100
+
101
+ ``` cpp
102
+ constexpr auto operator*() const;
103
+ ```
104
+
105
+ *Effects:* Equivalent to:
106
+
107
+ ``` cpp
108
+ return tuple-transform([](auto& i) -> decltype(auto) { return *i; }, current_);
109
+ ```
110
+
111
+ ``` cpp
112
+ constexpr iterator& operator++();
113
+ ```
114
+
115
+ *Effects:* Equivalent to:
116
+
117
+ ``` cpp
118
+ tuple-for-each([](auto& i) { ++i; }, current_);
119
+ return *this;
120
+ ```
121
+
122
+ ``` cpp
123
+ constexpr void operator++(int);
124
+ ```
125
+
126
+ *Effects:* Equivalent to `++*this`.
127
+
128
+ ``` cpp
129
+ constexpr iterator operator++(int) requires all-forward<Const, Views...>;
130
+ ```
131
+
132
+ *Effects:* Equivalent to:
133
+
134
+ ``` cpp
135
+ auto tmp = *this;
136
+ ++*this;
137
+ return tmp;
138
+ ```
139
+
140
+ ``` cpp
141
+ constexpr iterator& operator--() requires all-bidirectional<Const, Views...>;
142
+ ```
143
+
144
+ *Effects:* Equivalent to:
145
+
146
+ ``` cpp
147
+ tuple-for-each([](auto& i) { --i; }, current_);
148
+ return *this;
149
+ ```
150
+
151
+ ``` cpp
152
+ constexpr iterator operator--(int) requires all-bidirectional<Const, Views...>;
153
+ ```
154
+
155
+ *Effects:* Equivalent to:
156
+
157
+ ``` cpp
158
+ auto tmp = *this;
159
+ --*this;
160
+ return tmp;
161
+ ```
162
+
163
+ ``` cpp
164
+ constexpr iterator& operator+=(difference_type x)
165
+ requires all-random-access<Const, Views...>;
166
+ ```
167
+
168
+ *Effects:* Equivalent to:
169
+
170
+ ``` cpp
171
+ tuple-for-each([&]<class I>(I& i) { i += iter_difference_t<I>(x); }, current_);
172
+ return *this;
173
+ ```
174
+
175
+ ``` cpp
176
+ constexpr iterator& operator-=(difference_type x)
177
+ requires all-random-access<Const, Views...>;
178
+ ```
179
+
180
+ *Effects:* Equivalent to:
181
+
182
+ ``` cpp
183
+ tuple-for-each([&]<class I>(I& i) { i -= iter_difference_t<I>(x); }, current_);
184
+ return *this;
185
+ ```
186
+
187
+ ``` cpp
188
+ constexpr auto operator[](difference_type n) const
189
+ requires all-random-access<Const, Views...>;
190
+ ```
191
+
192
+ *Effects:* Equivalent to:
193
+
194
+ ``` cpp
195
+ return tuple-transform([&]<class I>(I& i) -> decltype(auto) {
196
+ return i[iter_difference_t<I>(n)];
197
+ }, current_);
198
+ ```
199
+
200
+ ``` cpp
201
+ friend constexpr bool operator==(const iterator& x, const iterator& y)
202
+ requires (equality_comparable<iterator_t<maybe-const<Const, Views>>> && ...);
203
+ ```
204
+
205
+ *Returns:*
206
+
207
+ - `x.`*`current_`*` == y.`*`current_`* if
208
+ `all-bidirectional<Const, Views...>` is `true`.
209
+ - Otherwise, `true` if there exists an integer
210
+ 0 ≤ i < `sizeof...(Views)` such that
211
+ `bool(std::get<`i`>(x.`*`current_`*`) == std::get<`i`>(y.`*`current_`*`))`
212
+ is `true`. \[*Note 1*: This allows `zip_view` to model `common_range`
213
+ when all constituent views model `common_range`. — *end note*]
214
+ - Otherwise, `false`.
215
+
216
+ ``` cpp
217
+ friend constexpr auto operator<=>(const iterator& x, const iterator& y)
218
+ requires all-random-access<Const, Views...>;
219
+ ```
220
+
221
+ *Returns:* `x.`*`current_`*` <=> y.`*`current_`*.
222
+
223
+ ``` cpp
224
+ friend constexpr iterator operator+(const iterator& i, difference_type n)
225
+ requires all-random-access<Const, Views...>;
226
+ friend constexpr iterator operator+(difference_type n, const iterator& i)
227
+ requires all-random-access<Const, Views...>;
228
+ ```
229
+
230
+ *Effects:* Equivalent to:
231
+
232
+ ``` cpp
233
+ auto r = i;
234
+ r += n;
235
+ return r;
236
+ ```
237
+
238
+ ``` cpp
239
+ friend constexpr iterator operator-(const iterator& i, difference_type n)
240
+ requires all-random-access<Const, Views...>;
241
+ ```
242
+
243
+ *Effects:* Equivalent to:
244
+
245
+ ``` cpp
246
+ auto r = i;
247
+ r -= n;
248
+ return r;
249
+ ```
250
+
251
+ ``` cpp
252
+ friend constexpr difference_type operator-(const iterator& x, const iterator& y)
253
+ requires (sized_sentinel_for<iterator_t<maybe-const<Const, Views>>,
254
+ iterator_t<maybe-const<Const, Views>>> && ...);
255
+ ```
256
+
257
+ Let *`DIST`*`(`i`)` be
258
+ `difference_type(std::get<`i`>(x.`*`current_`*`) - std::get<`i`>(y.`*`current_`*`))`.
259
+
260
+ *Returns:* The value with the smallest absolute value among
261
+ *`DIST`*`(`n`)` for all integers 0 ≤ n < `sizeof...(Views)`.
262
+
263
+ ``` cpp
264
+ friend constexpr auto iter_move(const iterator& i) noexcept(see below);
265
+ ```
266
+
267
+ *Effects:* Equivalent to:
268
+
269
+ ``` cpp
270
+ return tuple-transform(ranges::iter_move, i.current_);
271
+ ```
272
+
273
+ *Remarks:* The exception specification is equivalent to:
274
+
275
+ ``` cpp
276
+ (noexcept(ranges::iter_move(declval<const iterator_t<maybe-const<Const,
277
+ Views>>&>())) && ...) &&
278
+ (is_nothrow_move_constructible_v<range_rvalue_reference_t<maybe-const<Const,
279
+ Views>>> && ...)
280
+ ```
281
+
282
+ ``` cpp
283
+ friend constexpr void iter_swap(const iterator& l, const iterator& r) noexcept(see below)
284
+ requires (indirectly_swappable<iterator_t<maybe-const<Const, Views>>> && ...);
285
+ ```
286
+
287
+ *Effects:* For every integer 0 ≤ i < `sizeof...(Views)`, performs:
288
+
289
+ ``` cpp
290
+ ranges::iter_swap(std::get<i>(l.current_), std::get<i>(r.current_))
291
+ ```
292
+
293
+ *Remarks:* The exception specification is equivalent to the logical of
294
+ the following expressions:
295
+
296
+ ``` cpp
297
+ noexcept(ranges::iter_swap(std::get<i>(l.current_), std::get<i>(r.current_)))
298
+ ```
299
+
300
+ for every integer 0 ≤ i < `sizeof...(Views)`.
301
+