From Jason Turner

[range.slide.iterator]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmphsxs423s/{from.md → to.md} +282 -0
tmp/tmphsxs423s/{from.md → to.md} RENAMED
@@ -0,0 +1,282 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### Class template `slide_view::iterator` <a id="range.slide.iterator">[[range.slide.iterator]]</a>
2
+
3
+ ``` cpp
4
+ namespace std::ranges {
5
+ template<forward_range V>
6
+ requires view<V>
7
+ template<bool Const>
8
+ class slide_view<V>::iterator {
9
+ using Base = maybe-const<Const, V>; // exposition only
10
+ iterator_t<Base> current_ = iterator_t<Base>(); // exposition only
11
+ iterator_t<Base> last_ele_ = iterator_t<Base>(); // exposition only,
12
+ // present only if Base models slide-caches-first
13
+ range_difference_t<Base> n_ = 0; // exposition only
14
+
15
+ constexpr iterator(iterator_t<Base> current, range_difference_t<Base> n) // exposition only
16
+ requires (!slide-caches-first<Base>);
17
+
18
+ constexpr iterator(iterator_t<Base> current, iterator_t<Base> last_ele, // exposition only
19
+ range_difference_t<Base> n)
20
+ requires slide-caches-first<Base>;
21
+
22
+ public:
23
+ using iterator_category = input_iterator_tag;
24
+ using iterator_concept = see below;
25
+ using value_type = decltype(views::counted(current_, n_));
26
+ using difference_type = range_difference_t<Base>;
27
+
28
+ iterator() = default;
29
+ constexpr iterator(iterator<!Const> i)
30
+ requires Const && convertible_to<iterator_t<V>, iterator_t<Base>>;
31
+
32
+ constexpr auto operator*() const;
33
+ constexpr iterator& operator++();
34
+ constexpr iterator operator++(int);
35
+
36
+ constexpr iterator& operator--() requires bidirectional_range<Base>;
37
+ constexpr iterator operator--(int) requires bidirectional_range<Base>;
38
+
39
+ constexpr iterator& operator+=(difference_type x)
40
+ requires random_access_range<Base>;
41
+ constexpr iterator& operator-=(difference_type x)
42
+ requires random_access_range<Base>;
43
+
44
+ constexpr auto operator[](difference_type n) const
45
+ requires random_access_range<Base>;
46
+
47
+ friend constexpr bool operator==(const iterator& x, const iterator& y);
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& 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 auto operator<=>(const iterator& x, const iterator& y)
58
+ requires random_access_range<Base> &&
59
+ three_way_comparable<iterator_t<Base>>;
60
+
61
+ friend constexpr iterator operator+(const iterator& i, difference_type n)
62
+ requires random_access_range<Base>;
63
+ friend constexpr iterator operator+(difference_type n, const iterator& i)
64
+ requires random_access_range<Base>;
65
+ friend constexpr iterator operator-(const iterator& i, difference_type n)
66
+ requires random_access_range<Base>;
67
+ friend constexpr difference_type operator-(const iterator& x, const iterator& y)
68
+ requires sized_sentinel_for<iterator_t<Base>, iterator_t<Base>>;
69
+ };
70
+ }
71
+ ```
72
+
73
+ `iterator::iterator_concept` is defined as follows:
74
+
75
+ - If *`Base`* models `random_access_range`, then `iterator_concept`
76
+ denotes `random_access_iterator_tag`.
77
+ - Otherwise, if *`Base`* models `bidirectional_range`, then
78
+ `iterator_concept` denotes `bidirectional_iterator_tag`.
79
+ - Otherwise, `iterator_concept` denotes `forward_iterator_tag`.
80
+
81
+ If the invocation of any non-const member function of *`iterator`* exits
82
+ via an exception, the *`iterator`* acquires a singular value.
83
+
84
+ ``` cpp
85
+ constexpr iterator(iterator_t<Base> current, range_difference_t<Base> n)
86
+ requires (!slide-caches-first<Base>);
87
+ ```
88
+
89
+ *Effects:* Initializes *current\_* with `current` and *n\_* with `n`.
90
+
91
+ ``` cpp
92
+ constexpr iterator(iterator_t<Base> current, iterator_t<Base> last_ele,
93
+ range_difference_t<Base> n)
94
+ requires slide-caches-first<Base>;
95
+ ```
96
+
97
+ *Effects:* Initializes *current\_* with `current`, *last_ele\_* with
98
+ `last_ele`, and *n\_* with `n`.
99
+
100
+ ``` cpp
101
+ constexpr iterator(iterator<!Const> i)
102
+ requires Const && convertible_to<iterator_t<V>, iterator_t<Base>>;
103
+ ```
104
+
105
+ *Effects:* Initializes *current\_* with `std::move(i.`*`current_`*`)`
106
+ and *n\_* with `i.`*`n_`*.
107
+
108
+ [*Note 1*: *`iterator`*`<true>` can only be formed when *Base* models
109
+ `slide-caches-nothing`, in which case *last_ele\_* is not
110
+ present. — *end note*]
111
+
112
+ ``` cpp
113
+ constexpr auto operator*() const;
114
+ ```
115
+
116
+ *Returns:* `views::counted(`*`current_`*`, `*`n_`*`)`.
117
+
118
+ ``` cpp
119
+ constexpr iterator& operator++();
120
+ ```
121
+
122
+ *Preconditions:* *current\_* and *last_ele\_* (if present) are
123
+ incrementable.
124
+
125
+ *Ensures:* *current\_* and *last_ele\_* (if present) are each equal to
126
+ `ranges::next(i)`, where `i` is the value of that data member before the
127
+ call.
128
+
129
+ *Returns:* `*this`.
130
+
131
+ ``` cpp
132
+ constexpr iterator operator++(int);
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
+ *Preconditions:* *current\_* and *last_ele\_* (if present) are
148
+ decrementable.
149
+
150
+ *Ensures:* *current\_* and *last_ele\_* (if present) are each equal to
151
+ `ranges::prev(i)`, where `i` is the value of that data member before the
152
+ call.
153
+
154
+ *Returns:* `*this`.
155
+
156
+ ``` cpp
157
+ constexpr iterator operator--(int) requires bidirectional_range<Base>;
158
+ ```
159
+
160
+ *Effects:* Equivalent to:
161
+
162
+ ``` cpp
163
+ auto tmp = *this;
164
+ --*this;
165
+ return tmp;
166
+ ```
167
+
168
+ ``` cpp
169
+ constexpr iterator& operator+=(difference_type x)
170
+ requires random_access_range<Base>;
171
+ ```
172
+
173
+ *Preconditions:* *`current_`*` + x` and *`last_ele_`*` + x` (if
174
+ *last_ele\_* is present) have well-defined behavior.
175
+
176
+ *Ensures:* *current\_* and *last_ele\_* (if present) are each equal to
177
+ `i + x`, where `i` is the value of that data member before the call.
178
+
179
+ *Returns:* `*this`.
180
+
181
+ ``` cpp
182
+ constexpr iterator& operator-=(difference_type x)
183
+ requires random_access_range<Base>;
184
+ ```
185
+
186
+ *Preconditions:* *`current_`*` - x` and *`last_ele_`*` - x` (if
187
+ *last_ele\_* is present) have well-defined behavior.
188
+
189
+ *Ensures:* *current\_* and *last_ele\_* (if present) are each equal to
190
+ `i - x`, where `i` is the value of that data member before the call.
191
+
192
+ *Returns:* `*this`.
193
+
194
+ ``` cpp
195
+ constexpr auto operator[](difference_type n) const
196
+ requires random_access_range<Base>;
197
+ ```
198
+
199
+ *Effects:* Equivalent to:
200
+ `return views::counted(`*`current_`*` + n, `*`n_`*`);`
201
+
202
+ ``` cpp
203
+ friend constexpr bool operator==(const iterator& x, const iterator& y);
204
+ ```
205
+
206
+ *Returns:* If *last_ele\_* is present,
207
+ `x.`*`last_ele_`*` == y.`*`last_ele_`*; otherwise,
208
+ `x.`*`current_`*` == y.`*`current_`*.
209
+
210
+ ``` cpp
211
+ friend constexpr bool operator<(const iterator& x, const iterator& y)
212
+ requires random_access_range<Base>;
213
+ ```
214
+
215
+ *Returns:* `x.`*`current_`*` < y.`*`current_`*.
216
+
217
+ ``` cpp
218
+ friend constexpr bool operator>(const iterator& x, const iterator& y)
219
+ requires random_access_range<Base>;
220
+ ```
221
+
222
+ *Effects:* Equivalent to: `return y < x;`
223
+
224
+ ``` cpp
225
+ friend constexpr bool operator<=(const iterator& x, const iterator& y)
226
+ requires random_access_range<Base>;
227
+ ```
228
+
229
+ *Effects:* Equivalent to: `return !(y < x);`
230
+
231
+ ``` cpp
232
+ friend constexpr bool operator>=(const iterator& x, const iterator& y)
233
+ requires random_access_range<Base>;
234
+ ```
235
+
236
+ *Effects:* Equivalent to: `return !(x < y);`
237
+
238
+ ``` cpp
239
+ friend constexpr auto operator<=>(const iterator& x, const iterator& y)
240
+ requires random_access_range<Base> &&
241
+ three_way_comparable<iterator_t<Base>>;
242
+ ```
243
+
244
+ *Returns:* `x.`*`current_`*` <=> y.`*`current_`*.
245
+
246
+ ``` cpp
247
+ friend constexpr iterator operator+(const iterator& i, difference_type n)
248
+ requires random_access_range<Base>;
249
+ friend constexpr iterator operator+(difference_type n, const iterator& i)
250
+ requires random_access_range<Base>;
251
+ ```
252
+
253
+ *Effects:* Equivalent to:
254
+
255
+ ``` cpp
256
+ auto r = i;
257
+ r += n;
258
+ return r;
259
+ ```
260
+
261
+ ``` cpp
262
+ friend constexpr iterator operator-(const iterator& i, difference_type n)
263
+ requires random_access_range<Base>;
264
+ ```
265
+
266
+ *Effects:* Equivalent to:
267
+
268
+ ``` cpp
269
+ auto r = i;
270
+ r -= n;
271
+ return r;
272
+ ```
273
+
274
+ ``` cpp
275
+ friend constexpr difference_type operator-(const iterator& x, const iterator& y)
276
+ requires sized_sentinel_for<iterator_t<Base>, iterator_t<Base>>;
277
+ ```
278
+
279
+ *Returns:* If *last_ele\_* is present,
280
+ `x.`*`last_ele_`*` - y.`*`last_ele_`*; otherwise,
281
+ `x.`*`current_`*` - y.`*`current_`*.
282
+