You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -52,118 +52,87 @@ When you pass the compiler switch `/diagnostics:caret` to Visual Studio 2022 ver
52
52
53
53
Iterator concepts are defined in the `std` namespace as declared in the `<iterator>` header file. They're used in the declarations of [range adaptors](range-adaptors.md), [views](view-classes.md), and so on.
54
54
55
-
There are six categories of ranges. They are directly related to the categories of ranges listed in [`<iterator>](iterator.md#remarks).
55
+
There are six categories of iterators. They are directly related to the categories of ranges listed in [`<ranges>](ranges.md#remarks).
56
56
57
57
In order of increasing power, the categories are:
58
58
59
-
|Range concept | Description |
59
+
|Iterator concept | Description |
60
60
|--|--|
61
-
|[`output_range`](#output_range)| Specifies a range that you can write to. JTW It supports [output_iterator](iterators.md# JTW) Repeat this pattern for the entries below. |
62
-
|[`input_range`](#input_range)| Specifies a range that you can read from at least once. |
63
-
|[`forward_range`](#forward_range)| Specifies a range that can read (and possibly write) multiple times. |
64
-
|[`bidirectional_range`](#bidirectional_range)| Specifies a range that can read and write both forwards and backwards. |
65
-
|[`random_access_range`](#random_access_range)| Specifies a range that can read and write by index. |
66
-
|[`contiguous_range`](#contiguous_range)| Specifies a range whose elements are sequential in memory and can be accessed using pointer arithmetic. |
61
+
|[`input_or_output_iterator`](#input_or_output_iterator)| The basis of the iterator concept taxonomy. |
62
+
|[`output_iterator`](#output_iterator)| Specifies an iterator that you can write to. JTW It supports [output_iterator](iterators.md# JTW) Repeat this pattern for the entries below. |
63
+
|[`input_iterator`](#input_iterator)| Specifies an iterator that you can read from at least once. |
64
+
DONE | [`forward_iterator`](#forward_iterator) | Specifies an iterator that can read (and possibly write) multiple times. |
65
+
DONE | [`bidirectional_iterator`](#bidirectional_iterator) | Specifies an iterator that can read and write both forwards and backwards. |
66
+
|[`random_access_iterator`](#random_access_iterator)| Specifies an iterator that can read and write by index. |
67
+
DONE| [`contiguous_iterator`](#contiguous_iterator) | Specifies an iterator whose elements are sequential in memory and can be accessed using pointer arithmetic. |
67
68
68
-
In the preceding table, concepts are listed in order of increasing capability. A range that meets the requirements of a concept for a category generally meets the requirements of all concepts in the categories that precede it. For example, a `random_access_range` has the capability of a `bidirectional_range`, `forward_range`, `input_range`, and `output_range`. However, an exception is `input_range` which doesn't have the capability of an `output_range` because it can't be written to.
69
+
In the preceding table, concepts are listed in order of increasing capability. An iterator that meets the requirements of a concept for a category generally meets the requirements of the concepts in the rows that precede it. For example, a `random_access_iterator` has the capability of a `bidirectional_iterator`, `forward_iterator`, `input_iterator`, and `output_iterator`. However, an exception is `input_iterator` which doesn't have the capability of an `output_iterator` because it can't be written to.
69
70
70
-
Other range concepts include:
71
+
Other iterator concepts include:
71
72
72
73
| Range concept | Description |
73
74
|--|--|
74
-
|[`range`](#range)<sup>C++20</sup> | Specifies a type that provides an iterator and a sentinel. |
75
-
|[`borrowed_range`](#borrowed_range)<sup>C++20</sup> | Specifies that the lifetime of the range's iterators aren't tied to the range's lifetime. |
76
-
|[`common_range`](#common_range)<sup>C++20</sup> | Specifies that the type of the range's iterator and the type of the range's sentinel are the same. |
77
-
|[`Simple_View`](#simple_view)<sup>C++20</sup> | Not an official concept defined as part of the standard library, but used as a helper concept on some interfaces. |
78
-
|[`sized_range`](#sized_range)<sup>C++20</sup> | Specifies a range that can provide the number of elements in a range efficiently. |
79
-
|[`view`](#view)<sup>C++20</sup> | Specifies a type that has efficient (constant time) move construction, assignment, and destruction. |
80
-
|[`viewable_range`](#viewable_range)<sup>C++20</sup> | Specifies a type that either is a view or can be converted to one. |
The type to test to see if it's a `bidirectional_range`.
95
+
*`I`*\
96
+
The iterator to test to see if it's a `bidirectional_iterator`.
98
97
99
98
### Remarks
100
99
101
100
A `bidirectional_iterator` has the capabilities of a `forward_iterator`, but can also iterate backwards.
102
101
103
-
Some examples of a `bidirectional_range` are `std::set`, `std::vector`, and `std::list`.
102
+
Some examples of containers that can be used with a `bidirectional_iterator` are `std::set`, `std::vector`, and `std::list`.
104
103
105
-
## `borrowed_range`
104
+
## `contiguous_iterator`
106
105
107
-
A type models `borrowed_range` if the validity of iterators you get from the object can outlive the lifetime of the object. That is, the iterators for a range can be used even when the range no longer exists.
106
+
Specifies an iterator whose elements are sequential in memory and can be accessed using pointer arithmetic.
The elements of a `contiguous_iterator` are stored sequentially in memory and can be accessed using pointer arithmetic. For example, an array can be traversed using a `contiguous_iterator`.
135
126
136
127
### Remarks
137
128
138
-
Getting the type from `std::ranges::begin()` and `std::ranges::end()` is important for algorithms that calculate the distance between two iterators, and for algorithms that accept ranges denoted by iterator pairs.
129
+
A `contiguous_iterator` can be accessed by pointer arithmetic because the elements are laid out sequentially in memory and are the same size.
139
130
140
-
The standard containers (for example, `vector`) meet the requirements of `common_range`.
131
+
Some examples of a `contiguous_iterator` are `std::array`, `std::vector`, and `std::string`.
141
132
142
-
##`contiguous_range`
133
+
### Example: `contiguous_iterator`
143
134
144
-
The elements of a `contiguous_range` are stored sequentially in memory and can be accessed using pointer arithmetic. For example, an array is a `contiguous_range`.
The type to test to see if it's an `input_iterator`.
223
196
224
197
### Remarks
225
198
226
-
When a type meets the requirements of `input_range`:
199
+
When a type meets the requirements of `input_iterator`:
227
200
228
-
-The `ranges::begin()` function returns an `input_iterator`. Calling `begin()` more than once on an `input_range` results in undefined behavior.
229
-
- You can dereference an `input_iterator` repeatedly, which yields the same value each time. An `input_range` isn't multi-pass. Incrementing an iterator invalidates any copies.
201
+
- Calling `begin()` more than once on an `input_iterator` results in undefined behavior.
202
+
- You can dereference an `input_iterator` repeatedly, which yields the same value each time. An `input_iterator` isn't multi-pass. Incrementing an iterator invalidates any copies.
230
203
- It can be used with `ranges::for_each`.
231
-
- It *at least* has an `input_iterator`. It may have a more capable iterator type.
204
+
- It *at least* has an `input_iterator`. It may be a more capable iterator type.
232
205
233
-
## `output_range`
206
+
## `output_iterator`
234
207
235
-
An `output_range` is a range that you can write to.
208
+
An `output_iterator` is a range that you can write to.
The type to test to see if it's a `sized_iterator`.
268
241
269
242
### Remarks
270
243
271
-
A `random_access_range` is the most flexible iterator. It has the capabilities of an `input_range`, `output_range`, `forward_range`, and `bidirectional_range`. A `random_access_range` is also sortable.
244
+
A `random_access_iterator` is the most flexible iterator. It has the capabilities of an `input_iterator`, `output_iterator`, `forward_iterator`, and `bidirectional_iterator`. A `random_access_iterator` is also sortable.
272
245
273
-
Some examples of a `random_access_range` are `std::vector`, `std::array`, and `std::deque`.
246
+
Some examples of a `random_access_iterator` are `std::vector`, `std::array`, and `std::deque`.
274
247
275
248
## `range`
276
249
@@ -321,33 +294,33 @@ A view `V` is a [`Simple_View`](#simple_view) if all of the following are true:
321
294
-`const V` is a range
322
295
- Both `v` and `const V` have the same iterator and sentinel types.
323
296
324
-
## `sized_range`
297
+
## `sized_iterator`
325
298
326
-
A `sized_range` provides the number of elements in the range in amortized constant time.
299
+
A `sized_iterator` provides the number of elements in the range in amortized constant time.
327
300
328
301
```cpp
329
302
template<classT>
330
-
concept sized_range = range<T> &&
303
+
concept sized_iterator = range<T> &&
331
304
requires(T& t) { ranges::size(t); };
332
305
```
333
306
334
307
### Parameters
335
308
336
309
*`T`*\
337
-
The type to test to see if it's a `sized_range`.
310
+
The type to test to see if it's a `sized_iterator`.
338
311
339
312
### Remarks
340
313
341
-
The requirements of a `sized_range` are that calling `ranges::size` on it:
314
+
The requirements of a `sized_iterator` are that calling `ranges::size` on it:
342
315
343
316
- Doesn't modify the range.
344
317
- Returns the number of elements in amortized constant time. Amortized constant time doesn't mean O(1), but that the average cost over a series of calls, even in the worst case, is O(n) rather than O(n^2) or worse.
345
318
346
-
Some examples of a `sized_range` are `std::list` and `std::vector`.
319
+
Some examples of a `sized_iterator` are `std::list` and `std::vector`.
347
320
348
-
### Example: `sized_range`
321
+
### Example: `sized_iterator`
349
322
350
-
The following example shows that a `vector` of `int` is a `sized_range`:
323
+
The following example shows that a `vector` of `int` is a `sized_iterator`:
351
324
352
325
```cpp
353
326
// requires /std:c++20 or later
@@ -357,7 +330,7 @@ The following example shows that a `vector` of `int` is a `sized_range`:
0 commit comments