From Jason Turner

[range.iota]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp197ffnw_/{from.md → to.md} +59 -26
tmp/tmp197ffnw_/{from.md → to.md} RENAMED
@@ -6,49 +6,50 @@
6
  an initial value.
7
 
8
  The name `views::iota` denotes a customization point object
9
  [[customization.point.object]]. Given subexpressions `E` and `F`, the
10
  expressions `views::iota(E)` and `views::iota(E, F)` are
11
- expression-equivalent to `iota_view{E}` and `iota_view{E, F}`,
12
  respectively.
13
 
14
  [*Example 1*:
15
 
16
  ``` cpp
17
- for (int i : iota_view{1, 10})
18
- cout << i << ' '; // prints: 1 2 3 4 5 6 7 8 9
19
  ```
20
 
21
  — *end example*]
22
 
23
  #### Class template `iota_view` <a id="range.iota.view">[[range.iota.view]]</a>
24
 
25
  ``` cpp
26
  namespace std::ranges {
27
  template<class I>
28
- concept decrementable = // exposition only
29
- see below;
30
  template<class I>
31
- concept advanceable = // exposition only
32
- see below;
33
 
34
  template<weakly_incrementable W, semiregular Bound = unreachable_sentinel_t>
35
- requires weakly-equality-comparable-with<W, Bound> && semiregular<W>
36
  class iota_view : public view_interface<iota_view<W, Bound>> {
37
  private:
38
  // [range.iota.iterator], class iota_view::iterator
39
  struct iterator; // exposition only
 
40
  // [range.iota.sentinel], class iota_view::sentinel
41
  struct sentinel; // exposition only
 
42
  W value_ = W(); // exposition only
43
  Bound bound_ = Bound(); // exposition only
 
44
  public:
45
- iota_view() = default;
46
  constexpr explicit iota_view(W value);
47
- constexpr iota_view(type_identity_t<W> value,
48
- type_identity_t<Bound> bound);
49
- constexpr iota_view(iterator first, sentinel last) : iota_view(*first, last.bound_) {}
50
 
51
  constexpr iterator begin() const;
52
  constexpr auto end() const;
53
  constexpr iterator end() const requires same_as<W, Bound>;
54
 
@@ -76,11 +77,11 @@ Let `IOTA-DIFF-T(W)` be defined as follows:
76
 
77
  The exposition-only *decrementable* concept is equivalent to:
78
 
79
  ``` cpp
80
  template<class I>
81
- concept decrementable =
82
  incrementable<I> && requires(I i) {
83
  { --i } -> same_as<I&>;
84
  { i-- } -> same_as<I>;
85
  };
86
  ```
@@ -100,11 +101,11 @@ only if
100
 
101
  The exposition-only *advanceable* concept is equivalent to:
102
 
103
  ``` cpp
104
  template<class I>
105
- concept advanceable =
106
  decrementable<I> && totally_ordered<I> &&
107
  requires(I i, const I j, const IOTA-DIFF-T(I) n) {
108
  { i += n } -> same_as<I&>;
109
  { i -= n } -> same_as<I&>;
110
  I(j + n);
@@ -138,30 +139,49 @@ value `n` of type `D`. `I` models `advanceable` only if
138
  ``` cpp
139
  constexpr explicit iota_view(W value);
140
  ```
141
 
142
  *Preconditions:* `Bound` denotes `unreachable_sentinel_t` or `Bound()`
143
- is reachable from `value`.
 
144
 
145
  *Effects:* Initializes *value\_* with `value`.
146
 
147
  ``` cpp
148
- constexpr iota_view(type_identity_t<W> value, type_identity_t<Bound> bound);
149
  ```
150
 
151
  *Preconditions:* `Bound` denotes `unreachable_sentinel_t` or `bound` is
152
  reachable from `value`. When `W` and `Bound` model
153
  `totally_ordered_with`, then `bool(value <= bound)` is `true`.
154
 
155
  *Effects:* Initializes *value\_* with `value` and *bound\_* with
156
  `bound`.
157
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
158
  ``` cpp
159
  constexpr iterator begin() const;
160
  ```
161
 
162
- *Effects:* Equivalent to: `return iterator{`*`value_`*`};`
163
 
164
  ``` cpp
165
  constexpr auto end() const;
166
  ```
167
 
@@ -176,11 +196,11 @@ else
176
 
177
  ``` cpp
178
  constexpr iterator end() const requires same_as<W, Bound>;
179
  ```
180
 
181
- *Effects:* Equivalent to: `return iterator{bound_};`
182
 
183
  ``` cpp
184
  constexpr auto size() const requires see below;
185
  ```
186
 
@@ -195,33 +215,35 @@ if constexpr (is-integer-like<W> && is-integer-like<Bound>)
195
  : to-unsigned-like(bound_) - to-unsigned-like(value_);
196
  else
197
  return to-unsigned-like(bound_ - value_);
198
  ```
199
 
200
- *Remarks:* The expression in the *requires-clause* is equivalent to
201
 
202
  ``` cpp
203
- (same_as<W, Bound> && advanceable<W>) || (integral<W> && integral<Bound>) ||
204
  sized_sentinel_for<Bound, W>
205
  ```
206
 
207
  #### Class `iota_view::iterator` <a id="range.iota.iterator">[[range.iota.iterator]]</a>
208
 
209
  ``` cpp
210
  namespace std::ranges {
211
  template<weakly_incrementable W, semiregular Bound>
212
- requires weakly-equality-comparable-with<W, Bound>
213
  struct iota_view<W, Bound>::iterator {
214
  private:
215
  W value_ = W(); // exposition only
 
216
  public:
217
  using iterator_concept = see below;
218
- using iterator_category = input_iterator_tag;
 
219
  using value_type = W;
220
  using difference_type = IOTA-DIFF-T(W);
221
 
222
- iterator() = default;
223
  constexpr explicit iterator(W value);
224
 
225
  constexpr W operator*() const noexcept(is_nothrow_copy_constructible_v<W>);
226
 
227
  constexpr iterator& operator++();
@@ -435,11 +457,16 @@ friend constexpr auto operator<=>(const iterator& x, const iterator& y)
435
  ``` cpp
436
  friend constexpr iterator operator+(iterator i, difference_type n)
437
  requires advanceable<W>;
438
  ```
439
 
440
- *Effects:* Equivalent to: `return i += n;`
 
 
 
 
 
441
 
442
  ``` cpp
443
  friend constexpr iterator operator+(difference_type n, iterator i)
444
  requires advanceable<W>;
445
  ```
@@ -449,11 +476,16 @@ friend constexpr iterator operator+(difference_type n, iterator i)
449
  ``` cpp
450
  friend constexpr iterator operator-(iterator i, difference_type n)
451
  requires advanceable<W>;
452
  ```
453
 
454
- *Effects:* Equivalent to: `return i -= n;`
 
 
 
 
 
455
 
456
  ``` cpp
457
  friend constexpr difference_type operator-(const iterator& x, const iterator& y)
458
  requires advanceable<W>;
459
  ```
@@ -477,14 +509,15 @@ if constexpr (is-integer-like<W>) {
477
  #### Class `iota_view::sentinel` <a id="range.iota.sentinel">[[range.iota.sentinel]]</a>
478
 
479
  ``` cpp
480
  namespace std::ranges {
481
  template<weakly_incrementable W, semiregular Bound>
482
- requires weakly-equality-comparable-with<W, Bound>
483
  struct iota_view<W, Bound>::sentinel {
484
  private:
485
  Bound bound_ = Bound(); // exposition only
 
486
  public:
487
  sentinel() = default;
488
  constexpr explicit sentinel(Bound bound);
489
 
490
  friend constexpr bool operator==(const iterator& x, const sentinel& y);
 
6
  an initial value.
7
 
8
  The name `views::iota` denotes a customization point object
9
  [[customization.point.object]]. Given subexpressions `E` and `F`, the
10
  expressions `views::iota(E)` and `views::iota(E, F)` are
11
+ expression-equivalent to `iota_view(E)` and `iota_view(E, F)`,
12
  respectively.
13
 
14
  [*Example 1*:
15
 
16
  ``` cpp
17
+ for (int i : views::iota(1, 10))
18
+ cout << i << ' '; // prints 1 2 3 4 5 6 7 8 9
19
  ```
20
 
21
  — *end example*]
22
 
23
  #### Class template `iota_view` <a id="range.iota.view">[[range.iota.view]]</a>
24
 
25
  ``` cpp
26
  namespace std::ranges {
27
  template<class I>
28
+ concept exposition onlyconceptnc{decrementable} = see belownc; // exposition only
29
+
30
  template<class I>
31
+ concept exposition onlyconceptnc{advanceable} = see belownc; // exposition only
 
32
 
33
  template<weakly_incrementable W, semiregular Bound = unreachable_sentinel_t>
34
+ requires weakly-equality-comparable-with<W, Bound> && copyable<W>
35
  class iota_view : public view_interface<iota_view<W, Bound>> {
36
  private:
37
  // [range.iota.iterator], class iota_view::iterator
38
  struct iterator; // exposition only
39
+
40
  // [range.iota.sentinel], class iota_view::sentinel
41
  struct sentinel; // exposition only
42
+
43
  W value_ = W(); // exposition only
44
  Bound bound_ = Bound(); // exposition only
45
+
46
  public:
47
+ iota_view() requires default_initializable<W> = default;
48
  constexpr explicit iota_view(W value);
49
+ constexpr explicit iota_view(type_identity_t<W> value, type_identity_t<Bound> bound);
50
+ constexpr explicit iota_view(iterator first, see below last);
 
51
 
52
  constexpr iterator begin() const;
53
  constexpr auto end() const;
54
  constexpr iterator end() const requires same_as<W, Bound>;
55
 
 
77
 
78
  The exposition-only *decrementable* concept is equivalent to:
79
 
80
  ``` cpp
81
  template<class I>
82
+ concept decrementable = // exposition only
83
  incrementable<I> && requires(I i) {
84
  { --i } -> same_as<I&>;
85
  { i-- } -> same_as<I>;
86
  };
87
  ```
 
101
 
102
  The exposition-only *advanceable* concept is equivalent to:
103
 
104
  ``` cpp
105
  template<class I>
106
+ concept advanceable = // exposition only
107
  decrementable<I> && totally_ordered<I> &&
108
  requires(I i, const I j, const IOTA-DIFF-T(I) n) {
109
  { i += n } -> same_as<I&>;
110
  { i -= n } -> same_as<I&>;
111
  I(j + n);
 
139
  ``` cpp
140
  constexpr explicit iota_view(W value);
141
  ```
142
 
143
  *Preconditions:* `Bound` denotes `unreachable_sentinel_t` or `Bound()`
144
+ is reachable from `value`. When `W` and `Bound` model
145
+ `totally_ordered_with`, then `bool(value <= Bound())` is `true`.
146
 
147
  *Effects:* Initializes *value\_* with `value`.
148
 
149
  ``` cpp
150
+ constexpr explicit iota_view(type_identity_t<W> value, type_identity_t<Bound> bound);
151
  ```
152
 
153
  *Preconditions:* `Bound` denotes `unreachable_sentinel_t` or `bound` is
154
  reachable from `value`. When `W` and `Bound` model
155
  `totally_ordered_with`, then `bool(value <= bound)` is `true`.
156
 
157
  *Effects:* Initializes *value\_* with `value` and *bound\_* with
158
  `bound`.
159
 
160
+ ``` cpp
161
+ constexpr explicit iota_view(iterator first, see below last);
162
+ ```
163
+
164
+ *Effects:* Equivalent to:
165
+
166
+ - If `same_as<W, Bound>` is `true`,
167
+ `iota_view(first.`*`value_`*`, last.`*`value_`*`)`.
168
+ - Otherwise, if `Bound` denotes `unreachable_sentinel_t`,
169
+ `iota_view(first.`*`value_`*`, last)`.
170
+ - Otherwise, `iota_view(first.`*`value_`*`, last.`*`bound_`*`)`.
171
+
172
+ *Remarks:* The type of `last` is:
173
+
174
+ - If `same_as<W, Bound>` is `true`, *iterator*.
175
+ - Otherwise, if `Bound` denotes `unreachable_sentinel_t`, `Bound`.
176
+ - Otherwise, *sentinel*.
177
+
178
  ``` cpp
179
  constexpr iterator begin() const;
180
  ```
181
 
182
+ *Effects:* Equivalent to: `return `*`iterator`*`{`*`value_`*`};`
183
 
184
  ``` cpp
185
  constexpr auto end() const;
186
  ```
187
 
 
196
 
197
  ``` cpp
198
  constexpr iterator end() const requires same_as<W, Bound>;
199
  ```
200
 
201
+ *Effects:* Equivalent to: `return `*`iterator`*`{`*`bound_`*`};`
202
 
203
  ``` cpp
204
  constexpr auto size() const requires see below;
205
  ```
206
 
 
215
  : to-unsigned-like(bound_) - to-unsigned-like(value_);
216
  else
217
  return to-unsigned-like(bound_ - value_);
218
  ```
219
 
220
+ *Remarks:* The expression in the *requires-clause* is equivalent to:
221
 
222
  ``` cpp
223
+ (same_as<W, Bound> && advanceable<W>) || (is-integer-like<W> && is-integer-like<Bound>) ||
224
  sized_sentinel_for<Bound, W>
225
  ```
226
 
227
  #### Class `iota_view::iterator` <a id="range.iota.iterator">[[range.iota.iterator]]</a>
228
 
229
  ``` cpp
230
  namespace std::ranges {
231
  template<weakly_incrementable W, semiregular Bound>
232
+ requires weakly-equality-comparable-with<W, Bound> && copyable<W>
233
  struct iota_view<W, Bound>::iterator {
234
  private:
235
  W value_ = W(); // exposition only
236
+
237
  public:
238
  using iterator_concept = see below;
239
+ using iterator_category = input_iterator_tag; // present only if W models incrementable and
240
+ // IOTA-DIFF-T(W) is an integral type
241
  using value_type = W;
242
  using difference_type = IOTA-DIFF-T(W);
243
 
244
+ iterator() requires default_initializable<W> = default;
245
  constexpr explicit iterator(W value);
246
 
247
  constexpr W operator*() const noexcept(is_nothrow_copy_constructible_v<W>);
248
 
249
  constexpr iterator& operator++();
 
457
  ``` cpp
458
  friend constexpr iterator operator+(iterator i, difference_type n)
459
  requires advanceable<W>;
460
  ```
461
 
462
+ *Effects:* Equivalent to:
463
+
464
+ ``` cpp
465
+ i += n;
466
+ return i;
467
+ ```
468
 
469
  ``` cpp
470
  friend constexpr iterator operator+(difference_type n, iterator i)
471
  requires advanceable<W>;
472
  ```
 
476
  ``` cpp
477
  friend constexpr iterator operator-(iterator i, difference_type n)
478
  requires advanceable<W>;
479
  ```
480
 
481
+ *Effects:* Equivalent to:
482
+
483
+ ``` cpp
484
+ i -= n;
485
+ return i;
486
+ ```
487
 
488
  ``` cpp
489
  friend constexpr difference_type operator-(const iterator& x, const iterator& y)
490
  requires advanceable<W>;
491
  ```
 
509
  #### Class `iota_view::sentinel` <a id="range.iota.sentinel">[[range.iota.sentinel]]</a>
510
 
511
  ``` cpp
512
  namespace std::ranges {
513
  template<weakly_incrementable W, semiregular Bound>
514
+ requires weakly-equality-comparable-with<W, Bound> && copyable<W>
515
  struct iota_view<W, Bound>::sentinel {
516
  private:
517
  Bound bound_ = Bound(); // exposition only
518
+
519
  public:
520
  sentinel() = default;
521
  constexpr explicit sentinel(Bound bound);
522
 
523
  friend constexpr bool operator==(const iterator& x, const sentinel& y);