Skip to content

Commit 19c6724

Browse files
TylerMSFTTylerMSFTTyler Whitney
authored
Ranges concepts (#4538)
* start draft * draft * draft * draft * draft * draft * draft * finish raw draft * fix link * cleanup pass * added Simple_View * incorp tech review * remove quotes * fix merge conflict in toc * acrolinx * link concepts to definitions * added input_range links * concept linking Co-authored-by: TylerMSFT <Tyler.Whitney@microsoft.com> Co-authored-by: Tyler Whitney <tylerw6502@gmail.com>
1 parent 4aedea5 commit 19c6724

24 files changed

+506
-108
lines changed

docs/standard-library/basic-istream-view-class.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ For a description of the following entries, see [View class characteristics](vie
4949
| **Range adaptor** | [`istream`](range-adaptors.md#istream) |
5050
| **Underlying range** | None |
5151
| **Element type** |The same as `Val` |
52-
| **View iterator category** | `input_range` |
52+
| **View iterator category** | [`input_range`](range-concepts.md#input_range) |
5353
| **Sized** | No |
5454
| **Is `const`-iterable** | No |
5555
| **Common range** | No |

docs/standard-library/common-view-class.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ For a description of the following entries, see [View class characteristics](vie
3030
| Characteristic | Description |
3131
|--|--|
3232
| **Range adaptor** | [`views::common`](range-adaptors.md#common) |
33-
| **Underlying range** | Must satisfy `forward_range` or higher |
33+
| **Underlying range** | Must satisfy [`forward_range`](range-concepts.md#forward_range) or higher |
3434
| **Element type** | Same as the underlying range |
35-
| **View iterator category** | Supports `forward_range` or `random_access_range` when the underlying range satisfies `random_access_range` and `sized_range` |
36-
| **Sized** | Only if the underlying range satisfies `sized_range` |
35+
| **View iterator category** | Supports `forward_range` or [`random_access_range`](range-concepts.md#random_access_range) when the underlying range satisfies `random_access_range` and [`sized_range`](range-concepts.md#sized_range) |
36+
| **Sized** | Only if the underlying range satisfies [`sized_range`](range-concepts.md#sized_range) |
3737
| **Is `const`-iterable** | Only if the underlying range is `const` iterable |
3838
| **Common range** | Yes |
39-
| **Borrowed range** | Only if the underlying range satisfies `borrowed_range` |
39+
| **Borrowed range** | Only if the underlying range satisfies [`borrowed_range`](range-concepts.md#borrowed_range) |
4040
4141
## Members
4242

docs/standard-library/drop-view-class.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ For a description of the following entries, see [View class characteristics](vie
2929
| Characteristic | Description |
3030
|--|--|
3131
| **Range adaptor** | [`views::drop`](range-adaptors.md#drop) |
32-
| **Underlying range** | Must satisfy `output_range` or higher |
32+
| **Underlying range** | Must satisfy [`output_range`](range-concepts.md#output_range) or higher |
3333
| **Element type** | Same as the underlying range |
3434
| **View iterator category** | Same as the underlying range |
35-
| **Sized** | Only if the underlying range satisfies `sized_range` |
36-
| **Is `const`-iterable** | Only if the underlying range is `const` iterable and satisfies `random_access_range` and `sized_range` |
37-
| **Common range** | Only if the underlying range is a `common_range` |
38-
| **Borrowed range** | Only if the underlying range satisfies `borrowed_range` |
35+
| **Sized** | Only if the underlying range satisfies [`sized_range`](range-concepts.md#sized_range) |
36+
| **Is `const`-iterable** | Only if the underlying range is `const` iterable and satisfies [`random_access_range`](range-concepts.md#random_access_range) and [`sized_range`](range-concepts.md#sized_range) |
37+
| **Common range** | Only if the underlying range is a [`common_range`](range-concepts.md#common_range) |
38+
| **Borrowed range** | Only if the underlying range satisfies [`borrowed_range`](range-concepts.md#borrowed_range) |
3939
4040
## Members
4141
@@ -45,7 +45,7 @@ For a description of the following entries, see [View class characteristics](vie
4545
| [`base`](#base)<sup>C++20</sup> | Get the underlying view. |
4646
| [`begin`](#begin)<sup>C++20</sup> | Get an iterator to the first element. |
4747
| [`end`](#end)<sup>C++20</sup> | Get the sentinel at the end of the view. |
48-
| [`size`](#size)<sup>C++20</sup> | Get the number of elements in this view. The underlying range must satisfy `sized_range`. |
48+
| [`size`](#size)<sup>C++20</sup> | Get the number of elements in this view. The underlying range must satisfy [`sized_range`](range-concepts.md#sized_range). |
4949
| **Inherited from [`view_interface`](view-interface.md)** | **Description** |
5050
| [`back`](view-interface.md#back)<sup>C++20</sup> | Get the last element. |
5151
| [`data`](view-interface.md#data)<sup>C++20</sup> | Get a pointer to the first element. |
@@ -196,7 +196,7 @@ The number of elements in the `drop_view`.
196196

197197
### Remarks
198198

199-
The underlying range must satisfy `sized_range`.
199+
The underlying range must satisfy [`sized_range`](range-concepts.md#sized_range).
200200

201201
## See also
202202

docs/standard-library/drop-while-view-class.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ For a description of the following entries, see [View class characteristics](vie
3636
| Characteristic | Description |
3737
|--|--|
3838
| **Range adaptor** | [`views::drop_while`](range-adaptors.md#drop_while) |
39-
| **Underlying range** | Must satisfy `forward_range` or higher and the underlying range's iterators must model `sized_sentinel_for` |
39+
| **Underlying range** | Must satisfy [`forward_range`](range-concepts.md#forward_range) or higher and the underlying range's iterators must model `sized_sentinel_for` |
4040
| **Element type** | Same as the underlying range |
4141
| **View iterator category** | Same as the underlying range |
42-
| **Sized** | Only if the underlying range satisfies `random_access_range` |
42+
| **Sized** | Only if the underlying range satisfies [`random_access_range`](range-concepts.md#random_access_range) |
4343
| **Is `const`-iterable** | No |
44-
| **Common range** | Only if the underlying range satisfies `common_range` |
45-
| **Borrowed range** | Only if the underlying range satisfies `borrowed_range` |
44+
| **Common range** | Only if the underlying range satisfies [`common_range`](range-concepts.md#common_range) |
45+
| **Borrowed range** | Only if the underlying range satisfies [`borrowed_range`](range-concepts.md#borrowed_range) |
4646
4747
## Members
4848

docs/standard-library/elements-view-class.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ For a description of the following entries, see [View class characteristics](vie
3232
| Characteristic | Description |
3333
|--|--|
3434
| **Range adaptor** | [`views::elements`](range-adaptors.md#elements) |
35-
| **Underlying range** | Must satisfy `input_range` or higher |
35+
| **Underlying range** | Must satisfy [`input_range`](range-concepts.md#input_range) or higher |
3636
| **Element type** | Same as the type of the indexed tuple element |
37-
| **View iterator category** | `forward_range`, `bidirectional_range`, or `random_access_range` |
38-
| **Sized** | Only if the underlying range satisfies `sized_range` |
37+
| **View iterator category** | [`forward_range`](range-concepts.md#forward_range), [`bidirectional_range`](range-concepts.md#bidirectional_range), or [`random_access_range`](range-concepts.md#random_access_range) |
38+
| **Sized** | Only if the underlying range satisfies [`sized_range`](range-concepts.md#sized_range) |
3939
| **Is `const`-iterable** | Only if the underlying range satisfies `const-iterable` |
40-
| **Common range** | Only if the underlying range satisfies `common_range` |
41-
| **Borrowed range** | Only if the underlying range satisfies `borrowed_range` |
40+
| **Common range** | Only if the underlying range satisfies [`common_range`](range-concepts.md#common_range) |
41+
| **Borrowed range** | Only if the underlying range satisfies [`borrowed_range`](range-concepts.md#borrowed_range) |
4242
4343
## Members
4444
@@ -48,7 +48,7 @@ For a description of the following entries, see [View class characteristics](vie
4848
| [`base`](#base)<sup>C++20</sup> | Get the underlying range. |
4949
| [`begin`](#begin)<sup>C++20</sup> | Get an iterator to the first element. |
5050
| [`end`](#end)<sup>C++20</sup> | Get the sentinel at the end of the view. |
51-
| [`size`](#size)<sup>C++20</sup> | Get the number of elements in this view. The underlying range must satisfy `sized_range`. |
51+
| [`size`](#size)<sup>C++20</sup> | Get the number of elements in this view. The underlying range must satisfy [`sized_range`](range-concepts.md#sized_range). |
5252
| **Inherited from [`view_interface`](view-interface.md)** | **Description** |
5353
| [`back`](view-interface.md#back)<sup>C++20</sup> | Get the last element. |
5454
| [`empty`](view-interface.md#empty)<sup>C++20</sup> | Test whether the `elements_view` is empty. |
@@ -253,7 +253,7 @@ The number of elements in the `elements_view`.
253253

254254
### Remarks
255255

256-
The size of the view is only available if the underlying range is a `sized_range`, or in other words, bounded.
256+
The size of the view is only available if the underlying range is a [`sized_range`](range-concepts.md#sized_range), or in other words, bounded.
257257

258258
## See also
259259

docs/standard-library/filter-view-class.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ For a description of the following entries, see [View class characteristics](vie
3333
| Characteristic | Description |
3434
|--|--|
3535
| **Range adaptor** | [`views::filter`](range-adaptors.md#filter) |
36-
| **Underlying range** | Must satisfy `input_range` or higher |
36+
| **Underlying range** | Must satisfy [`input_range`](range-concepts.md#input_range) or higher |
3737
| **Element type** | Same as the underlying range |
38-
| **View iterator category** | Supports `input_range`, `forward_range`, or `bidirectional_range` depending on the underlying range |
38+
| **View iterator category** | Supports `input_range`, [`forward_range`](range-concepts.md#forward_range), or [`bidirectional_range`](range-concepts.md#bidirectional_range) depending on the underlying range |
3939
| **Sized** | No |
4040
| **Is `const`-iterable** | No |
41-
| **Common range** | Only if the underlying range satisfies `common_range` |
42-
| **Borrowed range** | Only if the underlying range satisfies `borrowed_range` |
41+
| **Common range** | Only if the underlying range satisfies [`common_range`](range-concepts.md#common_range) |
42+
| **Borrowed range** | Only if the underlying range satisfies [`borrowed_range`](range-concepts.md#borrowed_range) |
4343
4444
## Members
4545

docs/standard-library/iota-view-class.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ For a description of the following entries, see [View class characteristics](vie
3535
| **Range adaptor** | [`views::iota`](range-adaptors.md#iota) |
3636
| **Underlying range** | Not applicable because this view generates its members |
3737
| **Element type** | Same as the template parameter `W` |
38-
| **View iterator category** | Supports `input_range` up to `random_access_range`, depending on the type of `W` |
38+
| **View iterator category** | Supports [`input_range`](range-concepts.md#input_range) up to [`random_access_range`](range-concepts.md#random_access_range), depending on the type of `W` |
3939
| **Sized** | Only if the range has an end value, that is, it isn't an infinite series |
4040
| **Is `const`-iterable** | Yes |
4141
| **Common range** | Only if `Bound` is the same type as `W` |

docs/standard-library/join-view-class.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class join_view : public view_interface<join_view<R>>;
2121
### Template parameters
2222
2323
*`R`*\
24-
The type of the underlying range. Must satisfy `input_range` or better.
24+
The type of the underlying range. Must satisfy [`input_range`](range-concepts.md#input_range) or higher.
2525
2626
## View characteristics
2727
@@ -30,12 +30,12 @@ For a description of the following entries, see [View class characteristics](vie
3030
| Characteristic | Description |
3131
|--|--|
3232
| **Range adaptor** | [`views::join`](range-adaptors.md#join) |
33-
| **Underlying range** | Must satisfy `input_range` or higher |
33+
| **Underlying range** | Must satisfy [`input_range`](range-concepts.md#input_range) or higher |
3434
| **Element type** | Same as the underlying range |
35-
| **View iterator category** | Supports `input_range` up to `bidirectional_range` depending on the underlying range being iterated |
35+
| **View iterator category** | Supports `input_range` up to [`bidirectional_range`](range-concepts.md#bidirectional_range) depending on the underlying range being iterated |
3636
| **Sized** | No |
3737
| **Is `const`-iterable** | Only if the underlying range is `const` iterable |
38-
| **Common range** | Only if the underlying range satisfies `common_range` |
38+
| **Common range** | Only if the underlying range satisfies [`common_range`](range-concepts.md#common_range) |
3939
| **Borrowed range** | No |
4040
4141
## Members

docs/standard-library/keys-view-class.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ For a description of the following entries, see [View class characteristics](vie
3131
| Characteristic | Description |
3232
|--|--|
3333
| **Range adaptor** | [`views::keys`](range-adaptors.md#keys) |
34-
| **Underlying range** | Must satisfy `input_range` or higher |
34+
| **Underlying range** | Must satisfy [`input_range`](range-concepts.md#input_range) or higher |
3535
| **Element type** | Same as the type of the first tuple element of the underlying range |
36-
| **View iterator category** | `random_access_range` if the underlying range is contiguous, otherwise the same as the underlying range |
37-
| **Sized** | Only if the underlying range satisfies `sized_range` |
36+
| **View iterator category** | [`random_access_range`](range-concepts.md#random_access_range) if the underlying range is contiguous, otherwise the same as the underlying range |
37+
| **Sized** | Only if the underlying range satisfies [`sized_range`](range-concepts.md#sized_range) |
3838
| **Is `const`-iterable** | Only if the underlying range satisfies `const-iterable` |
39-
| **Common range** | Only if the underlying range satisfies `common_range` |
40-
| **Borrowed range** | Only if the underlying range satisfies `borrowed_range` |
39+
| **Common range** | Only if the underlying range satisfies [`common_range`](range-concepts.md#common_range) |
40+
| **Borrowed range** | Only if the underlying range satisfies [`borrowed_range`](range-concepts.md#borrowed_range) |
4141

4242
## Members
4343

@@ -49,7 +49,7 @@ The following list of member functions refers to the `keys_view` class. Recall t
4949
| [`base`](#base)<sup>C++20</sup> | Get the underlying range. |
5050
| [`begin`](#begin)<sup>C++20</sup> | Get an iterator to the first element. |
5151
| [`end`](#end)<sup>C++20</sup> | Get the sentinel at the end of the view. |
52-
| [`size`](#size)<sup>C++20</sup> | Get the number of elements. The underlying range must satisfy `sized_range`. |
52+
| [`size`](#size)<sup>C++20</sup> | Get the number of elements. The underlying range must satisfy [`sized_range`](range-concepts.md#sized_range). |
5353
| **Inherited from [`view_interface`](view-interface.md)** | **Description** |
5454
| [`back`](view-interface.md#back)<sup>C++20</sup> | Get the last element. |
5555
| [`empty`](view-interface.md#empty)<sup>C++20</sup> | Test whether the `keys_view` is empty. |
@@ -237,7 +237,7 @@ The number of elements in the `keys_view`.
237237

238238
### Remarks
239239

240-
The size of the view is only available if the underlying range is a `sized_range`, or in other words, bounded.
240+
The size of the view is only available if the underlying range is a [`sized_range`](range-concepts.md#sized_range), or in other words, bounded.
241241

242242
## See also
243243

docs/standard-library/lazy-split-view-class.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ dev_langs: ["C++"]
1111

1212
Splits a range into subranges based on a delimiter. The delimiter can be a single element or a view of elements. The delimiter isn't part of the resulting subranges.
1313

14-
The primary differences between a `split_view` and a `lazy_split_view` are:
14+
The primary differences between a [`split_view`](split-view-class.md) and a `lazy_split_view` are:
1515

1616
| **View** | **Can split a `const` range** | **range type** |
1717
|--|--|
18-
| `split_view` | no | Supports `forward_range` or better. |
19-
| `lazy_split_view` | yes | Supports `input_range` or better. |
18+
| `split_view` | no | Supports [`forward_range`](range-concepts.md#forward_range) or higher. |
19+
| `lazy_split_view` | yes | Supports [`input_range`](range-concepts.md#input_range) or higher. |
2020

21-
What makes a `lazy_split_view` "lazy" is that it doesn't lookahead for the next delimiter. That means it can support `input_range` whereas `split_view` requires at least `forward_range`. This is because `input_range` is single-pass whereas `forward_range` allows multi-pass iteration.
21+
What makes a `lazy_split_view` "lazy" is that it doesn't lookahead for the next delimiter. That means it can support [`input_range`](range-concepts.md#input_range) whereas `split_view` requires at least `forward_range`. This is because `input_range` is single-pass whereas `forward_range` allows multi-pass iteration.
2222

2323
Prefer `split_view` because it's more efficient--unless you must split a range that is `const`. Regarding performance, `split_view` is more efficient.
2424

@@ -38,7 +38,7 @@ class lazy_split_view : public view_interface<lazy_split_view<V, Pattern>>
3838
3939
*`Pattern`*\
4040
The type of the view that specifies a delimiter sequence.\
41-
The `(forward_range<V> || tiny-range <Pattern>)` requirement means that when the underlying range isn't `forward_range`, the delimiter must be a `tiny_range`. A `tiny_range` is a range with static extent whose size is 0 or 1. `tiny_range<T>` requires `sized_range<T>`, and `T::size()` must be a constant-expression that's less than or equal to 1.
41+
The `(forward_range<V> || tiny-range <Pattern>)` requirement means that when the underlying range isn't [`forward_range`](range-concepts.md#forward_range), the delimiter must be a `tiny_range`. A `tiny_range` is a range with static extent whose size is 0 or 1. `tiny_range<T>` requires `sized_range<T>`, and `T::size()` must be a constant-expression that's less than or equal to 1.
4242
4343
*`V`*\
4444
The type of the underlying view.
@@ -48,11 +48,11 @@ The `(forward_range<V> || tiny-range <Pattern>)` requirement means that when the
4848
For a description of the following entries, see [View class characteristics](view-classes.md#view-classes-characteristics)
4949
5050
**Range adaptor:** [`lazy_split`](range-adaptors.md#lazy_split)
51-
**Underlying range:** must satisfy `input_range` or higher
51+
**Underlying range:** must satisfy [`input_range`](range-concepts.md#input_range) or higher
5252
**View iterator category:** same as the underlying range
5353
**Element type:** collection of `range_reference_t<V>`
5454
**Sized:** no
55-
**Common range:** Yes when the underlying range is both `forward_range` and `common`.
55+
**Common range:** Yes when the underlying range is both [`forward_range`](range-concepts.md#forward_range) and `common`.
5656
**Borrowed range:** no
5757
**Is `const`-iterable:** only if the underlying range satisfies `forward_range` and is `const`-iterable
5858

0 commit comments

Comments
 (0)