From Jason Turner

[range.zip.transform.iterator]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp2qcnh4zc/{from.md → to.md} +239 -0
tmp/tmp2qcnh4zc/{from.md → to.md} RENAMED
@@ -0,0 +1,239 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### Class template `zip_transform_view::iterator` <a id="range.zip.transform.iterator">[[range.zip.transform.iterator]]</a>
2
+
3
+ ``` cpp
4
+ namespace std::ranges {
5
+ template<move_constructible F, input_range... Views>
6
+ requires (view<Views> && ...) && (sizeof...(Views) > 0) && is_object_v<F> &&
7
+ regular_invocable<F&, range_reference_t<Views>...> &&
8
+ can-reference<invoke_result_t<F&, range_reference_t<Views>...>>
9
+ template<bool Const>
10
+ class zip_transform_view<F, Views...>::iterator {
11
+ using Parent = maybe-const<Const, zip_transform_view>; // exposition only
12
+ using Base = maybe-const<Const, InnerView>; // exposition only
13
+ Parent* parent_ = nullptr; // exposition only
14
+ ziperator<Const> inner_; // exposition only
15
+
16
+ constexpr iterator(Parent& parent, ziperator<Const> inner); // exposition only
17
+
18
+ public:
19
+ using iterator_category = see belownc; // not always present
20
+ using iterator_concept = typename ziperator<Const>::iterator_concept;
21
+ using value_type =
22
+ remove_cvref_t<invoke_result_t<maybe-const<Const, F>&,
23
+ range_reference_t<maybe-const<Const, Views>>...>>;
24
+ using difference_type = range_difference_t<Base>;
25
+
26
+ iterator() = default;
27
+ constexpr iterator(iterator<!Const> i)
28
+ requires Const && convertible_to<ziperator<false>, ziperator<Const>>;
29
+
30
+ constexpr decltype(auto) operator*() const noexcept(see below);
31
+ constexpr iterator& operator++();
32
+ constexpr void operator++(int);
33
+ constexpr iterator operator++(int) requires forward_range<Base>;
34
+
35
+ constexpr iterator& operator--() requires bidirectional_range<Base>;
36
+ constexpr iterator operator--(int) requires bidirectional_range<Base>;
37
+
38
+ constexpr iterator& operator+=(difference_type x) requires random_access_range<Base>;
39
+ constexpr iterator& operator-=(difference_type x) requires random_access_range<Base>;
40
+
41
+ constexpr decltype(auto) operator[](difference_type n) const
42
+ requires random_access_range<Base>;
43
+
44
+ friend constexpr bool operator==(const iterator& x, const iterator& y)
45
+ requires equality_comparable<ziperator<Const>>;
46
+
47
+ friend constexpr auto operator<=>(const iterator& x, const iterator& y)
48
+ requires random_access_range<Base>;
49
+
50
+ friend constexpr iterator operator+(const iterator& i, difference_type n)
51
+ requires random_access_range<Base>;
52
+ friend constexpr iterator operator+(difference_type n, const iterator& i)
53
+ requires random_access_range<Base>;
54
+ friend constexpr iterator operator-(const iterator& i, difference_type n)
55
+ requires random_access_range<Base>;
56
+ friend constexpr difference_type operator-(const iterator& x, const iterator& y)
57
+ requires sized_sentinel_for<ziperator<Const>, ziperator<Const>>;
58
+ };
59
+ }
60
+ ```
61
+
62
+ The member *typedef-name* `iterator::iterator_category` is defined if
63
+ and only if *`Base`* models `forward_range`. In that case,
64
+ `iterator::iterator_category` is defined as follows:
65
+
66
+ - If
67
+ ``` cpp
68
+ invoke_result_t<maybe-const<Const, F>&, range_reference_t<maybe-const<Const, Views>>...>
69
+ ```
70
+
71
+ is not a reference, `iterator_category` denotes `input_iterator_tag`.
72
+ - Otherwise, let `Cs` denote the pack of types
73
+ `iterator_traits<iterator_t<maybe-const<Const, Views>>>::iterator_category...`.
74
+ - If `(derived_from<Cs, random_access_iterator_tag> && ...)` is
75
+ `true`, `iterator_category` denotes `random_access_iterator_tag`.
76
+ - Otherwise, if
77
+ `(derived_from<Cs, bidirectional_iterator_tag> && ...)` is `true`,
78
+ `iterator_category` denotes `bidirectional_iterator_tag`.
79
+ - Otherwise, if `(derived_from<Cs, forward_iterator_tag> && ...)` is
80
+ `true`, `iterator_category` denotes `forward_iterator_tag`.
81
+ - Otherwise, `iterator_category` denotes `input_iterator_tag`.
82
+
83
+ ``` cpp
84
+ constexpr iterator(Parent& parent, ziperator<Const> inner);
85
+ ```
86
+
87
+ *Effects:* Initializes *parent\_* with `addressof(parent)` and *inner\_*
88
+ with `std::move(inner)`.
89
+
90
+ ``` cpp
91
+ constexpr iterator(iterator<!Const> i)
92
+ requires Const && convertible_to<ziperator<false>, ziperator<Const>>;
93
+ ```
94
+
95
+ *Effects:* Initializes *parent\_* with `i.`*`parent_`* and *inner\_*
96
+ with `std::move(i.`*`inner_`*`)`.
97
+
98
+ ``` cpp
99
+ constexpr decltype(auto) operator*() const noexcept(see below);
100
+ ```
101
+
102
+ *Effects:* Equivalent to:
103
+
104
+ ``` cpp
105
+ return apply([&](const auto&... iters) -> decltype(auto) {
106
+ return invoke(*parent_->fun_, *iters...);
107
+ }, inner_.current_);
108
+ ```
109
+
110
+ *Remarks:* Let `Is` be the pack `0, 1, …, ``(sizeof...(Views)-1)`. The
111
+ exception specification is equivalent to:
112
+ `noexcept(invoke(*`*`parent_`*`->`*`fun_`*`, *std::get<Is>(`*`inner_`*`.`*`current_`*`)...))`.
113
+
114
+ ``` cpp
115
+ constexpr iterator& operator++();
116
+ ```
117
+
118
+ *Effects:* Equivalent to:
119
+
120
+ ``` cpp
121
+ ++inner_;
122
+ return *this;
123
+ ```
124
+
125
+ ``` cpp
126
+ constexpr void operator++(int);
127
+ ```
128
+
129
+ *Effects:* Equivalent to: `++*this`.
130
+
131
+ ``` cpp
132
+ constexpr iterator operator++(int) requires forward_range<Base>;
133
+ ```
134
+
135
+ *Effects:* Equivalent to:
136
+
137
+ ``` cpp
138
+ auto tmp = *this;
139
+ ++*this;
140
+ return tmp;
141
+ ```
142
+
143
+ ``` cpp
144
+ constexpr iterator& operator--() requires bidirectional_range<Base>;
145
+ ```
146
+
147
+ *Effects:* Equivalent to:
148
+
149
+ ``` cpp
150
+ --inner_;
151
+ return *this;
152
+ ```
153
+
154
+ ``` cpp
155
+ constexpr iterator operator--(int) requires bidirectional_range<Base>;
156
+ ```
157
+
158
+ *Effects:* Equivalent to:
159
+
160
+ ``` cpp
161
+ auto tmp = *this;
162
+ --*this;
163
+ return tmp;
164
+ ```
165
+
166
+ ``` cpp
167
+ constexpr iterator& operator+=(difference_type x)
168
+ requires random_access_range<Base>;
169
+ ```
170
+
171
+ *Effects:* Equivalent to:
172
+
173
+ ``` cpp
174
+ inner_ += x;
175
+ return *this;
176
+ ```
177
+
178
+ ``` cpp
179
+ constexpr iterator& operator-=(difference_type x)
180
+ requires random_access_range<Base>;
181
+ ```
182
+
183
+ *Effects:* Equivalent to:
184
+
185
+ ``` cpp
186
+ inner_ -= x;
187
+ return *this;
188
+ ```
189
+
190
+ ``` cpp
191
+ constexpr decltype(auto) operator[](difference_type n) const
192
+ requires random_access_range<Base>;
193
+ ```
194
+
195
+ *Effects:* Equivalent to:
196
+
197
+ ``` cpp
198
+ return apply([&]<class... Is>(const Is&... iters) -> decltype(auto) {
199
+ return invoke(*parent_->fun_, iters[iter_difference_t<Is>(n)]...);
200
+ }, inner_.current_);
201
+ ```
202
+
203
+ ``` cpp
204
+ friend constexpr bool operator==(const iterator& x, const iterator& y)
205
+ requires equality_comparable<ziperator<Const>>;
206
+ friend constexpr auto operator<=>(const iterator& x, const iterator& y)
207
+ requires random_access_range<Base>;
208
+ ```
209
+
210
+ Let *op* be the operator.
211
+
212
+ *Effects:* Equivalent to:
213
+ `return x.`*`inner_`*` `*`op`*` y.`*`inner_`*`;`
214
+
215
+ ``` cpp
216
+ friend constexpr iterator operator+(const iterator& i, difference_type n)
217
+ requires random_access_range<Base>;
218
+ friend constexpr iterator operator+(difference_type n, const iterator& i)
219
+ requires random_access_range<Base>;
220
+ ```
221
+
222
+ *Effects:* Equivalent to:
223
+ `return `*`iterator`*`(*i.`*`parent_`*`, i.`*`inner_`*` + n);`
224
+
225
+ ``` cpp
226
+ friend constexpr iterator operator-(const iterator& i, difference_type n)
227
+ requires random_access_range<Base>;
228
+ ```
229
+
230
+ *Effects:* Equivalent to:
231
+ `return `*`iterator`*`(*i.`*`parent_`*`, i.`*`inner_`*` - n);`
232
+
233
+ ``` cpp
234
+ friend constexpr difference_type operator-(const iterator& x, const iterator& y)
235
+ requires sized_sentinel_for<ziperator<Const>, ziperator<Const>>;
236
+ ```
237
+
238
+ *Effects:* Equivalent to: `return x.`*`inner_`*` - y.`*`inner_`*`;`
239
+