Skip to content

Commit 23b7ced

Browse files
TylerMSFTTylerMSFT
authored andcommitted
fix link
1 parent 2b9467f commit 23b7ced

File tree

3 files changed

+18
-20
lines changed

3 files changed

+18
-20
lines changed

docs/standard-library/iterator-concepts.md

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,18 @@ There are six categories of iterators. They're directly related to the categorie
5656

5757
The following iterator concepts are listed in order of increasing capability. `input_or_output_iterator` is at the low end of the capability hierarchy, and `contiguous_iterator` is at the high end. Iterators higher in the hierarchy can generally be used in place of those that are lower, but not vice-versa. For example, a `random_access_iterator` iterator can be used in place of a `forward_iterator`, but not the other way around. An exception is `input_iterator`, which can't be used in place of `output_iterator` because it can't write.
5858

59-
| Iterator concept | Description | Direction | Read/write | Multi-pass | Example types that use this iterator |
59+
In the following table, "Multi-pass" refers to whether the iterator can revisit the same element more than once. For example, `vector::iterator` is a multi-pass iterator because you can make a copy of the iterator, read the elements in the collection, and then restore the iterator to the value in the copy, and revisit the same elements again. If an iterator is single-pass, you can only visit the elements in the collection once.
60+
61+
In the following table, "Types" refers to the types of collections/iterators that satisfy the concept.
62+
63+
| Iterator concept | Description | Direction | Read/write | Multi-pass | Types |
6064
|--|--|--|--|--|--|
61-
| [`input_or_output_iterator`](#input_or_output_iterator)<sup>C++20</sup> | The basis of the iterator concept taxonomy. | Forward | Read or write | no | `std::istream_iterator`, `std::ostream_iterator` |
65+
| [`input_or_output_iterator`](#input_or_output_iterator)<sup>C++20</sup> | The basis of the iterator concept taxonomy. | Forward | Read/write | no | `istream_iterator`, `ostream_iterator` |
6266
| [`output_iterator`](#output_iterator)<sup>C++20</sup> | Test for an iterator that you can write to. | Forward | Write | no | `ostream`, `inserter` |
6367
| [`input_iterator`](#input_iterator)<sup>C++20</sup> | Test for an iterator that you can read from at least once. | Forward | Read | no | `istream`, `istreambuf_iterator` |
64-
| [`forward_iterator`](#forward_iterator)<sup>C++20</sup> | Test for an iterator that can read (and possibly write) multiple times. | Forward | Read/write | yes | `vector::iterator`, `list::iterator` |
68+
| [`forward_iterator`](#forward_iterator)<sup>C++20</sup> | Test for an iterator that can read (and possibly write) multiple times. | Forward | Read/write | yes | `vector`, `list` |
6569
| [`bidirectional_iterator`](#bidirectional_iterator)<sup>C++20</sup> | Test for an iterator that can read and write both forwards and backwards. | Forward/backward | Read/write | yes | `list`, `set`, `multiset`, `map`, and `multimap`. |
66-
| [`random_access_iterator`](#random_access_iterator)<sup>C++20</sup> | Test for an iterator that can read and write by index. | Forward/Backward | Read/write | yes | `vector::iterator`, `array::iterator`, `deque::iterator` |
70+
| [`random_access_iterator`](#random_access_iterator)<sup>C++20</sup> | Test for an iterator that can read and write by index. | Forward/Backward | Read/write | yes | `vector`, `array`, `deque` |
6771
| [`contiguous_iterator`](#contiguous_iterator)<sup>C++20</sup> | Test for an iterator whose elements are sequential in memory and can be accessed using pointer arithmetic. | Forward/backward | Read/write | yes | `array`, `vector` `string`.|
6872

6973
Other iterator concepts include:
@@ -97,7 +101,7 @@ The iterator to test to see if it's a `bidirectional_iterator`.
97101
98102
A `bidirectional_iterator` has the capabilities of a `forward_iterator`, but can also iterate backwards.
99103
100-
Some examples of containers that can be used with a `bidirectional_iterator` are `std::set`, `std::vector`, and `std::list`.
104+
Some examples of containers that can be used with a `bidirectional_iterator` are `set`, `vector`, and `list`.
101105
102106
### Example: `bidirectional_iterator`
103107
@@ -139,13 +143,9 @@ template<class I>
139143
*`I`*\
140144
The type to test to see if it's a `contiguous_iterator`.
141145
142-
The elements of a `contiguous_iterator` are stored sequentially in memory and can be accessed using pointer arithmetic. A `std::array` has a `contiguous_iterator`.
143-
144146
### Remarks
145147
146-
A `contiguous_iterator` can be accessed by pointer arithmetic because the elements are laid out sequentially in memory and are the same size.
147-
148-
Some examples of a `contiguous_iterator` are `std::array`, `std::vector`, and `std::string`.
148+
A `contiguous_iterator` can be accessed by pointer arithmetic because the elements are laid out sequentially in memory and are the same size. Some examples of a `contiguous_iterator` are `array`, `vector`, and `string`.
149149
150150
### Example: `contiguous_iterator`
151151
@@ -189,7 +189,7 @@ The iterator to test to see if it's a `forward_iterator`.
189189

190190
A `forward_iterator` can only move forward.
191191

192-
Some examples of containers that can be used with a `forward_iterator` are `std::unordered_set`, `std::unordered_multiset`, `std::unordered_map`, and `std::unordered_multimap`.
192+
Some examples of containers that can be used with a `forward_iterator` are `unordered_set`, `unordered_multiset`, `unordered_map`, and `unordered_multimap`.
193193

194194
### Example: `forward_iterator`
195195

@@ -231,9 +231,7 @@ The type to test to see if it's an `input_iterator`.
231231
232232
### Remarks
233233
234-
When a type meets the requirements of `input_iterator`:
235-
236-
- Calling `begin()` more than once on an `input_iterator` results in undefined behavior. This implies that if a type only models `input_iterator`, it isn't multi-pass and can read an element only once. Consider reading from standard input (`cin`) for example. In this case, you can only read the current element once and you can't re-read characters you've already read. You can only read an `input_iterator` forward, not backwards.
234+
Calling `begin()` on an `input_iterator` more than once results in undefined behavior. This implies that if a type only models `input_iterator`, it isn't multi-pass and can read an element only once. Consider reading from standard input (`cin`) for example. In this case, you can only read the current element once and you can't re-read characters you've already read. An `input_iterator` only reads forward, not backwards.
237235
238236
### Example: `input_iterator`
239237
@@ -368,7 +366,7 @@ The type to test to see if it's a `random_access_iterator`.
368366
369367
A `random_access_iterator` has the capabilities of an `input_iterator`, `output_iterator`, `forward_iterator`, and `bidirectional_iterator`.
370368
371-
Some examples of a `random_access_iterator` are `std::vector`, `std::array`, and `std::deque`.
369+
Some examples of a `random_access_iterator` are `vector`, `array`, and `deque`.
372370
373371
### Example: `random_access_iterator`
374372
@@ -416,7 +414,7 @@ A sentinel is a type that can be compared to an iterator to determine if the ite
416414
417415
### Example: `sentinel_for`
418416
419-
The following example uses the `sentinel_for` concept to show that `std::vector<int>::iterator` is a sentinel for `vector<int>`:
417+
The following example uses the `sentinel_for` concept to show that `vector<int>::iterator` is a sentinel for `vector<int>`:
420418
421419
```cpp
422420
// requires /std:c++20 or later
@@ -434,7 +432,7 @@ int main()
434432

435433
## `sized_sentinel_for`
436434

437-
Test that an iterator and its sentinel can be subtracted (using `-`) to find the difference in constant time.
435+
Test that an iterator and its sentinel can be subtracted using `-` to find the difference, in constant time.
438436

439437
```cpp
440438
template<class S, class I>

docs/standard-library/iterator.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ Visual Studio has added extensions to C++ Standard Library iterators to support
8989

9090
## Concepts
9191

92-
The following concepts are defined in the `std` namespace. They apply to iterators, and are related to the iterator categories for ranges described in [`<ranges>` concepts](range-concepts.md).
92+
The following concepts are defined in the `std` namespace. They apply to iterators, and are directly related to the iterator categories for ranges described in [`<ranges>` concepts](range-concepts.md).
9393

9494
| Iterator concept | Description |
9595
|--|--|
9696
| [`bidirectional_iterator`](iterator-concepts.md#bidirectional_iterator)<sup>C++20</sup> | Specifies an iterator that can read and write both forwards and backwards. |
97-
| [`contiguous_iterator`](iterator-concepts.md#contiguous_iterator)<sup>C++20</sup> | Specifies an iterator whose elements are sequential in memory and can be accessed using pointer arithmetic. |
97+
| [`contiguous_iterator`](iterator-concepts.md#contiguous_iterator)<sup>C++20</sup> | Specifies an iterator whose elements are sequential in memory, and can be accessed using pointer arithmetic. |
9898
| [`forward_iterator`](iterator-concepts.md#forward_iterator)<sup>C++20</sup> | Specifies an iterator that can read (and possibly write) multiple times. |
9999
| [`input_iterator`](iterator-concepts.md#input_iterator)<sup>C++20</sup> | Specifies an iterator that you can read from at least once. |
100100
| [`input_or_output_iterator`](iterator-concepts.md#input_or_output_iterator)<sup>C++20</sup> | The basis of the iterator concept taxonomy. |

docs/standard-library/view-classes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ Many of these classes have corresponding [range adaptors](range-adaptors.md) in
130130
Each view class topic has a **Characteristics** section after the syntax section. The **Characteristics** section has the following entries:
131131

132132
* **Range adaptor**: A link to the range adaptor that creates the view. You typically use a range adaptor to create a view rather than create a view class directly, so it's listed here for convenience.
133-
* **Underlying range**: Views have different iterator requirements for the kind of underlying range that they can use. See [ranges iterator hierarchy](#ranges_iterator_hierarchy) for more information about the kinds of iterators.
133+
* **Underlying range**: Views have different iterator requirements for the kind of underlying range that they can use. See [ranges iterator hierarchy](#ranges-iterator-hierarchy) for more information about the kinds of iterators.
134134
* **View iterator category**: The iterator category of the view. When a view adapts a range, the iterator type for the view is typically the same as the iterator type of the underlying range. However, it might be different for some views. For example, `reverse_view` has a `bidirectional_iterator`, even if the underlying range has a `random_access_iterator`.
135135
* **Element type**: The type of the elements that the view's iterator returns.
136136
* **Sized**: Whether the view can return the number of elements that it refers to. Not all views can.

0 commit comments

Comments
 (0)