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
Concepts are a C++20 language feature that constrain template parameters at compile time. They help prevent incorrect template instantiation, specify template argument requirements in a readable form, and provide more succinct template related compiler errors.
10
+
Concepts are a C++20 language feature that constrains template parameters at compile time. They help prevent incorrect template instantiation, specify template argument requirements in a readable form, and provide more succinct template related compiler errors.
11
11
12
12
Consider the following example, which defines a concept to prevent instantiating a template with a type that doesn't support division:
13
13
@@ -52,7 +52,7 @@ 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 iterators. They are directly related to the categories of ranges listed under [Range concepts](ranges.md#range-concepts).
55
+
There are six categories of iterators. They're directly related to the categories of ranges listed under [Range concepts](ranges.md#range-concepts).
56
56
57
57
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.
58
58
@@ -411,7 +411,7 @@ The type to test to see if it's a sentinel for `I`.
411
411
412
412
### Remarks
413
413
414
-
A sentinel is a type that can be compared to an iterator to determine if the iterator has reached the end. This concept determines if a type is a sentinel for one of the `input_or_output_iterator` types which includes `input_iterator`, `output_iterator`, `forward_iterator`, `bidirectional_iterator`, `random_access_iterator`, and `contiguous_iterator`.
414
+
A sentinel is a type that can be compared to an iterator to determine if the iterator has reached the end. This concept determines if a type is a sentinel for one of the `input_or_output_iterator` types, which includes `input_iterator`, `output_iterator`, `forward_iterator`, `bidirectional_iterator`, `random_access_iterator`, and `contiguous_iterator`.
Copy file name to clipboardExpand all lines: docs/standard-library/iterator-functions.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -236,7 +236,7 @@ int main()
236
236
160 106 80 70 53 40 35 23 20 16 10 8 5 4 2 1
237
237
```
238
238
239
-
The function `reverse_sort` supports containers of any kind, in addition to regular arrays, because it calls the non-member version of `begin()`. If`reverse_sort` were coded to use the container member `begin()`:
239
+
The function `reverse_sort` supports containers of any kind, in addition to regular arrays, because it calls the non-member version of `begin()`. Coding`reverse_sort` to use the container member `begin()`:
240
240
241
241
```cpp
242
242
template <typename C>
@@ -249,7 +249,7 @@ void reverse_sort(C& c) {
249
249
}
250
250
```
251
251
252
-
Then sending an array to it would cause this compiler error:
252
+
Then sending an array to it, causes this compiler error:
253
253
254
254
```Output
255
255
error C2228: left of '.begin' must have class/struct/union
@@ -1031,7 +1031,7 @@ The template function returns `next` decremented `off` times.
1031
1031
1032
1032
## <aname="rbegin"></a> `rbegin`
1033
1033
1034
-
Get an iterator which returns the elements of the container in reverse order.
1034
+
Get an iterator, which returns the elements of the container in reverse order.
1035
1035
1036
1036
```cpp
1037
1037
template <classC> constexprautorbegin(C& c) -> decltype(c.rbegin());
Copy file name to clipboardExpand all lines: docs/standard-library/iterator.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ Defines predefined iterators and stream iterators, iterator primitives, and supp
19
19
20
20
Iterators are a generalization of pointers that allow a C++ program to work with different data structures in a uniform way. Instead of operating on specific data types, algorithms operate on a range of values as specified by a kind of iterator. Algorithms can operate on any data structure that satisfies the requirements of the iterator.
21
21
22
-
In C++20, there are 6 categories of iterators. Iterators are arranged in a hierarchy of capability. Their capabilities are specified by C++20 concepts. For a description of the various iterators and their capabilities, see [Iterator concepts](iterator-concepts.md)
22
+
In C++20, there are six categories of iterators. Iterators are arranged in a hierarchy of capability. Their capabilities are specified by C++20 concepts. For a description of the various iterators and their capabilities, see [Iterator concepts](iterator-concepts.md)
23
23
24
24
Visual Studio has added extensions to C++ Standard Library iterators to support debugging for checked and unchecked iterators. For more information, see [Safe Libraries: C++ Standard Library](../standard-library/safe-libraries-cpp-standard-library.md).
Copy file name to clipboardExpand all lines: docs/standard-library/range-adaptors.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,7 +50,7 @@ When a range adaptor produces a view, it doesn't incur the cost of transforming
50
50
51
51
Creating a view is preparation to do work in the future. In the previous example, creating the view doesn't result in finding all the elements divisible by three or squaring those elements. Work happens only when you access an element in the view.
52
52
53
-
Elements of a view are usually the actual elements of the range used to create the view. The view usually doesn't own the elements; it just refers to them. Although ([`owning_view`](owning-view-class.md) is an exception. Changing an element changes that element in the range that the view was created from. The following example shows this behavior:
53
+
Elements of a view are usually the actual elements of the range used to create the view. The view usually doesn't own the elements; it just refers to them. Although [`owning_view`](owning-view-class.md) is an exception. Changing an element changes that element in the range that the view was created from. The following example shows this behavior:
Concepts are a C++20 language feature that constrain template parameters at compile time. They help prevent incorrect template instantiation, specify template argument requirements in a readable form, and provide more succinct template related compiler errors.
10
+
Concepts are a C++20 language feature that constrains template parameters at compile time. They help prevent incorrect template instantiation, specify template argument requirements in a readable form, and provide more succinct template related compiler errors.
11
11
12
12
Consider the following example, which defines a concept to prevent instantiating a template with a type that doesn't support division:
13
13
@@ -52,7 +52,7 @@ When you pass the compiler switch `/diagnostics:caret` to Visual Studio 2022 ver
52
52
53
53
Range concepts are defined in the `std::ranges` namespace as declared in the `<ranges>` 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 related to the categories of iterators listed in [`<iterator>` concepts](iterator-concepts.md). In order of increasing capability, the categories are:
55
+
There are six categories of ranges. They're related to the categories of iterators listed in [`<iterator>` concepts](iterator-concepts.md). In order of increasing capability, the categories are:
56
56
57
57
| Range concept | Description |
58
58
|--|--|
@@ -63,7 +63,7 @@ There are six categories of ranges. They are related to the categories of iterat
63
63
|[`random_access_range`](#random_access_range)| Specifies a range that can read and write by index. |
64
64
|[`contiguous_range`](#contiguous_range)| Specifies a range whose elements are sequential in memory and can be accessed using pointer arithmetic. |
65
65
66
-
In the preceding table, concepts are listed in order of increasing capability. A range that meets the requirements of a concept generally meets the requirements of the concepts in the rows 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.
66
+
In the preceding table, concepts are listed in order of increasing capability. A range that meets the requirements of a concept generally meets the requirements of the concepts in the rows that precede it. For example, a `random_access_range` has the capability of a `bidirectional_range`, `forward_range`, `input_range`, and `output_range`. Except `input_range`, which doesn't have the capability of an `output_range` because it can't be written to.
67
67
68
68
Other range concepts include:
69
69
@@ -94,7 +94,7 @@ The type to test to see if it's a `bidirectional_range`.
94
94
95
95
### Remarks
96
96
97
-
This kind of range supports [`bidirectional_iterator`](iterator-concepts.md#bidirectional_iterator) or above.
97
+
This kind of range supports [`bidirectional_iterator`](iterator-concepts.md#bidirectional_iterator) or greater.
98
98
A `bidirectional_iterator` has the capabilities of a `forward_iterator`, but can also iterate backwards.
99
99
100
100
Some examples of a `bidirectional_range` are `std::set`, `std::vector`, and `std::list`.
@@ -154,7 +154,7 @@ The type to test to see if it's a `contiguous_range`.
154
154
155
155
### Remarks
156
156
157
-
A `contiguous_range` can be accessed by pointer arithmetic because the elements are laid out sequentially in memory and are the same size. This kind of range supports [`continguous_iterator`](iterator-concepts.md#contiguous_iterator) which is the most flexible of all the iterators.
157
+
A `contiguous_range` can be accessed by pointer arithmetic because the elements are laid out sequentially in memory and are the same size. This kind of range supports [`continguous_iterator`](iterator-concepts.md#contiguous_iterator), which is the most flexible of all the iterators.
158
158
159
159
Some examples of a `contiguous_range` are `std::array`, `std::vector`, and `std::string`.
160
160
@@ -202,7 +202,7 @@ The type to test to see if it's a `forward_range`.
202
202
203
203
### Remarks
204
204
205
-
This kind of range supports [`forward_iterator`](iterator-concepts.md#forward_iterator) or above. A `forward_iterator` can iterate over a range multiple times.
205
+
This kind of range supports [`forward_iterator`](iterator-concepts.md#forward_iterator) or greater. A `forward_iterator` can iterate over a range multiple times.
206
206
207
207
## `input_range`
208
208
@@ -225,7 +225,7 @@ When a type meets the requirements of `input_range`:
225
225
- The `ranges::begin()` function returns an `input_iterator`. Calling `begin()` more than once on an `input_range` results in undefined behavior.
226
226
- 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.
227
227
- It can be used with `ranges::for_each`.
228
-
- It supports [`input_iterator`](iterator-concepts.md#input_iterator) or above.
228
+
- It supports [`input_iterator`](iterator-concepts.md#input_iterator) or greater.
229
229
230
230
## `output_range`
231
231
@@ -246,7 +246,7 @@ The type of the data to write to the range.
246
246
247
247
### Remarks
248
248
249
-
The meaning of `output_iterator<iterator_t<R>, T>` is that the type provides an iterator that can write values of type `T` to a range of type `R`. In other words, it supports [`output_iterator`](iterator-concepts.md#output_iterator) or above.
249
+
The meaning of `output_iterator<iterator_t<R>, T>` is that the type provides an iterator that can write values of type `T` to a range of type `R`. In other words, it supports [`output_iterator`](iterator-concepts.md#output_iterator) or greater.
250
250
251
251
## `random_access_range`
252
252
@@ -265,7 +265,7 @@ The type to test to see if it's a `sized_range`.
265
265
266
266
### Remarks
267
267
268
-
This kind of range supports [`random_access_iterator`](iterator-concepts.md#random_access_iterator) or above. A `random_access_range` has the capabilities of an `input_range`, `output_range`, `forward_range`, and `bidirectional_range`. A `random_access_range` is sortable.
268
+
This kind of range supports [`random_access_iterator`](iterator-concepts.md#random_access_iterator) or greater. A `random_access_range` has the capabilities of an `input_range`, `output_range`, `forward_range`, and `bidirectional_range`. A `random_access_range` is sortable.
269
269
270
270
Some examples of a `random_access_range` are `std::vector`, `std::array`, and `std::deque`.
A *view* is a lightweight range that refers to elements that it doesn't own (with the exception of[`owning_view`](owning-view-class.md)). A view is typically based on another range and provides a different way of looking at it, whether by transforming or filtering it. For example, [`std::views::filter`](filter-view-class.md) is a view that uses the criteria that you specify to select elements from another range.
10
+
A *view* is a lightweight range that refers to elements that it doesn't own (except[`owning_view`](owning-view-class.md)). A view is typically based on another range and provides a different way of looking at it, whether by transforming or filtering it. For example, [`std::views::filter`](filter-view-class.md) is a view that uses the criteria that you specify to select elements from another range.
11
11
12
12
When you access the elements in a view, it's done "lazily" so that work is done only when you get an element. This makes it possible to combine, or *compose*, views without a performance penalty.
13
13
@@ -157,9 +157,9 @@ In the **Characteristics** section of each view class topic, the iterator catego
157
157
|[`random_access_range`](range-concepts.md#random_access_range)| Can access the collection with an index; multi-pass. |
158
158
|[`contiguous_range`](range-concepts.md#contiguous_range)| Can access the collection with an index, and elements are stored contiguously in memory. |
159
159
160
-
Generally speaking, an iterator has the capability of the iterators that precede it in the table. For example, [`bidirectional_range`](range-concepts.md#bidirectional_range) has the capabilities of [`forward_range`](range-concepts.md#forward_range), but not vice versa. An exception is `input_range` which doesn't have the capability of `output_range` because you can't write to an `input_range`.
160
+
Generally speaking, an iterator has the capability of the iterators that precede it in the table. For example, [`bidirectional_range`](range-concepts.md#bidirectional_range) has the capabilities of [`forward_range`](range-concepts.md#forward_range), but not vice versa. Except `input_range`, which doesn't have the capability of `output_range` because you can't write to an `input_range`.
161
161
162
-
The statement "requires `input_range` or higher" means that the view can be used with an `input_range`, `forward_range`, `bidirectional_range`, `random_access_range`, or `contiguous_range` iterator, because they are all as capable as `input_range`.
162
+
The statement "requires `input_range` or higher" means that the view can be used with an `input_range`, `forward_range`, `bidirectional_range`, `random_access_range`, or `contiguous_range` iterator, because they're all as capable as `input_range`.
163
163
164
164
The ranges iterator hierarchy is directly related to the iterator hierarchy. For more information, see [Iterator concepts](iterator-concepts.md).
0 commit comments