From Jason Turner

[range.elements.iterator]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpcmy80h2v/{from.md → to.md} +244 -0
tmp/tmpcmy80h2v/{from.md → to.md} RENAMED
@@ -0,0 +1,244 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### Class template `elements_view::iterator` <a id="range.elements.iterator">[[range.elements.iterator]]</a>
2
+
3
+ ``` cpp
4
+ namespace std::ranges {
5
+ template<input_range V, size_t N>
6
+ requires view<V> && has-tuple-element<range_value_t<V>, N> &&
7
+ has-tuple-element<remove_reference_t<range_reference_t<V>>, N>
8
+ template<bool Const>
9
+ class elements_view<V, N>::iterator { // exposition only
10
+ using Base = conditional_t<Const, const V, V>; // exposition only
11
+
12
+ iterator_t<Base> current_ = iterator_t<Base>();
13
+ public:
14
+ using iterator_category = typename iterator_traits<iterator_t<Base>>::iterator_category;
15
+ using value_type = remove_cvref_t<tuple_element_t<N, range_value_t<Base>>>;
16
+ using difference_type = range_difference_t<Base>;
17
+
18
+ iterator() = default;
19
+ constexpr explicit iterator(iterator_t<Base> current);
20
+ constexpr iterator(iterator<!Const> i)
21
+ requires Const && convertible_to<iterator_t<V>, iterator_t<Base>>;
22
+
23
+ constexpr iterator_t<Base> base() const&
24
+ requires copyable<iterator_t<Base>>;
25
+ constexpr iterator_t<Base> base() &&;
26
+
27
+ constexpr decltype(auto) operator*() const
28
+ { return get<N>(*current_); }
29
+
30
+ constexpr iterator& operator++();
31
+ constexpr void operator++(int) requires (!forward_range<Base>);
32
+ constexpr iterator operator++(int) requires forward_range<Base>;
33
+
34
+ constexpr iterator& operator--() requires bidirectional_range<Base>;
35
+ constexpr iterator operator--(int) requires bidirectional_range<Base>;
36
+
37
+ constexpr iterator& operator+=(difference_type x)
38
+ requires random_access_range<Base>;
39
+ constexpr iterator& operator-=(difference_type x)
40
+ requires random_access_range<Base>;
41
+
42
+ constexpr decltype(auto) operator[](difference_type n) const
43
+ requires random_access_range<Base>
44
+ { return get<N>(*(current_ + n)); }
45
+
46
+ friend constexpr bool operator==(const iterator& x, const iterator& y)
47
+ requires equality_comparable<iterator_t<Base>>;
48
+
49
+ friend constexpr bool operator<(const iterator& x, const iterator& y)
50
+ requires random_access_range<Base>;
51
+ friend constexpr bool operator>(const iterator& x, const iterator& y)
52
+ requires random_access_range<Base>;
53
+ friend constexpr bool operator<=(const iterator& y, 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 auto operator<=>(const iterator& x, const iterator& y)
58
+ requires random_access_range<Base> && three_way_comparable<iterator_t<Base>>;
59
+
60
+ friend constexpr iterator operator+(const iterator& x, difference_type y)
61
+ requires random_access_range<Base>;
62
+ friend constexpr iterator operator+(difference_type x, const iterator& y)
63
+ requires random_access_range<Base>;
64
+ friend constexpr iterator operator-(const iterator& x, difference_type y)
65
+ requires random_access_range<Base>;
66
+ friend constexpr difference_type operator-(const iterator& x, const iterator& y)
67
+ requires random_access_range<Base>;
68
+ };
69
+ }
70
+ ```
71
+
72
+ ``` cpp
73
+ constexpr explicit iterator(iterator_t<Base> current);
74
+ ```
75
+
76
+ *Effects:* Initializes *current\_* with `std::move(current)`.
77
+
78
+ ``` cpp
79
+ constexpr iterator(iterator<!Const> i)
80
+ requires Const && convertible_to<iterator_t<V>, iterator_t<Base>>;
81
+ ```
82
+
83
+ *Effects:* Initializes *current\_* with `std::move(i.`*`current_`*`)`.
84
+
85
+ ``` cpp
86
+ constexpr iterator_t<Base> base() const&
87
+ requires copyable<iterator_t<Base>>;
88
+ ```
89
+
90
+ *Effects:* Equivalent to: `return `*`current_`*`;`
91
+
92
+ ``` cpp
93
+ constexpr iterator_t<Base> base() &&;
94
+ ```
95
+
96
+ *Effects:* Equivalent to: `return std::move(`*`current_`*`);`
97
+
98
+ ``` cpp
99
+ constexpr iterator& operator++();
100
+ ```
101
+
102
+ *Effects:* Equivalent to:
103
+
104
+ ``` cpp
105
+ ++current_;
106
+ return *this;
107
+ ```
108
+
109
+ ``` cpp
110
+ constexpr void operator++(int) requires (!forward_range<Base>);
111
+ ```
112
+
113
+ *Effects:* Equivalent to: `++`*`current_`*.
114
+
115
+ ``` cpp
116
+ constexpr iterator operator++(int) requires forward_range<Base>;
117
+ ```
118
+
119
+ *Effects:* Equivalent to:
120
+
121
+ ``` cpp
122
+ auto temp = *this;
123
+ ++current_;
124
+ return temp;
125
+ ```
126
+
127
+ ``` cpp
128
+ constexpr iterator& operator--() requires bidirectional_range<Base>;
129
+ ```
130
+
131
+ *Effects:* Equivalent to:
132
+
133
+ ``` cpp
134
+ --current_;
135
+ return *this;
136
+ ```
137
+
138
+ ``` cpp
139
+ constexpr iterator operator--(int) requires bidirectional_range<Base>;
140
+ ```
141
+
142
+ *Effects:* Equivalent to:
143
+
144
+ ``` cpp
145
+ auto temp = *this;
146
+ --current_;
147
+ return temp;
148
+ ```
149
+
150
+ ``` cpp
151
+ constexpr iterator& operator+=(difference_type n);
152
+ requires random_access_range<Base>;
153
+ ```
154
+
155
+ *Effects:* Equivalent to:
156
+
157
+ ``` cpp
158
+ current_ += n;
159
+ return *this;
160
+ ```
161
+
162
+ ``` cpp
163
+ constexpr iterator& operator-=(difference_type n)
164
+ requires random_access_range<Base>;
165
+ ```
166
+
167
+ *Effects:* Equivalent to:
168
+
169
+ ``` cpp
170
+ current_ -= n;
171
+ return *this;
172
+ ```
173
+
174
+ ``` cpp
175
+ friend constexpr bool operator==(const iterator& x, const iterator& y)
176
+ requires equality_comparable<Base>;
177
+ ```
178
+
179
+ *Effects:* Equivalent to: `return x.`*`current_`*` == y.`*`current_`*`;`
180
+
181
+ ``` cpp
182
+ friend constexpr bool operator<(const iterator& x, const iterator& y)
183
+ requires random_access_range<Base>;
184
+ ```
185
+
186
+ *Effects:* Equivalent to: `return x.`*`current_`*` < y.`*`current_`*`;`
187
+
188
+ ``` cpp
189
+ friend constexpr bool operator>(const iterator& x, const iterator& y)
190
+ requires random_access_range<Base>;
191
+ ```
192
+
193
+ *Effects:* Equivalent to: `return y < x;`
194
+
195
+ ``` cpp
196
+ friend constexpr bool operator<=(const iterator& x, const iterator& y)
197
+ requires random_access_range<Base>;
198
+ ```
199
+
200
+ *Effects:* Equivalent to: `return !(y < x);`
201
+
202
+ ``` cpp
203
+ friend constexpr bool operator>=(const iterator& x, const iterator& y)
204
+ requires random_access_range<Base>;
205
+ ```
206
+
207
+ *Effects:* Equivalent to: `return !(x < y);`
208
+
209
+ ``` cpp
210
+ friend constexpr auto operator<=>(const iterator& x, const iterator& y)
211
+ requires random_access_range<Base> && three_way_comparable<iterator_t<Base>>;
212
+ ```
213
+
214
+ *Effects:* Equivalent to:
215
+ `return x.`*`current_`*` <=> y.`*`current_`*`;`
216
+
217
+ ``` cpp
218
+ friend constexpr iterator operator+(const iterator& x, difference_type y)
219
+ requires random_access_range<Base>;
220
+ ```
221
+
222
+ *Effects:* Equivalent to: `return iterator{x} += y;`
223
+
224
+ ``` cpp
225
+ friend constexpr iterator operator+(difference_type x, const iterator& y)
226
+ requires random_access_range<Base>;
227
+ ```
228
+
229
+ *Effects:* Equivalent to: `return y + x;`
230
+
231
+ ``` cpp
232
+ constexpr iterator operator-(const iterator& x, difference_type y)
233
+ requires random_access_range<Base>;
234
+ ```
235
+
236
+ *Effects:* Equivalent to: `return iterator{x} -= y;`
237
+
238
+ ``` cpp
239
+ constexpr difference_type operator-(const iterator& x, const iterator& y)
240
+ requires random_access_range<Base>;
241
+ ```
242
+
243
+ *Effects:* Equivalent to: `return x.`*`current_`*` - y.`*`current_`*`;`
244
+