Skip to content

Commit 2155469

Browse files
committed
reverting adaptor
1 parent 6e04d55 commit 2155469

File tree

3 files changed

+45
-45
lines changed

3 files changed

+45
-45
lines changed

docs/standard-library/range-adaptors.md

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
---
2-
description: "Learn more about range adapters, which create views on ranges."
3-
title: "Range adapters"
2+
description: "Learn more about range adaptors, which create views on ranges."
3+
title: "Range adaptors"
44
ms.date: 10/19/2022
55
f1_keywords: ["ranges/std::all", "ranges/std::all_t", "ranges/std::common", "ranges/std::counted", "ranges/std::drop", "ranges/std::drop_while", "ranges/std::elements", "ranges/std::filter", "ranges/std::iota", "ranges/std::join", "ranges/std::keys", "ranges/std::lazy_split", "ranges/std::reverse", "ranges/std::split", "ranges/std::subrange", "ranges/std::take", "ranges/std::take_while", "ranges/std::transform"]
66
helpviewer_keywords: ["std::ranges [C++], all", "std::ranges [C++], all_t", "std::ranges [C++], common", "std::ranges [C++], counted", "std::ranges [C++], drop", "std::ranges [C++], drop_while", "std::ranges [C++], elements", "std::ranges [C++], filter", "std::ranges [C++], iota", "std::ranges [C++], join", "std::ranges [C++], keys", "std::ranges [C++], lazy_split", "std::ranges [C++], reverse", "std::ranges [C++], split", "std::ranges [C++], subrange", "std::ranges [C++], take", "std::ranges [C++], take_while", "std::ranges [C++], transform"]
77
---
8-
# Range adapters
8+
# Range adaptors
99

10-
Range adapters create a *view* (one of the [view classes](view-classes.md) in the `std::views` namespace) from a range. We recommend that you use an adapter in `std::ranges::views` instead of creating the view types directly. The adapters are the intended way to access views. They're easier to use, and in some cases more efficient, than creating instances of the view types directly.
10+
Range adaptors create a *view* (one of the [view classes](view-classes.md) in the `std::views` namespace) from a range. We recommend that you use an adaptor in `std::ranges::views` instead of creating the view types directly. The adaptors are the intended way to access views. They're easier to use, and in some cases more efficient, than creating instances of the view types directly.
1111

1212
A view is a lightweight object that refers to elements from a range. A view can:
1313

@@ -44,9 +44,9 @@ int main()
4444
0 9 36 81
4545
```
4646

47-
The first range adapter, `std::views::filter`, provides a view that contains the elements from `input` that are divisible by three. The other range adapter, `std::views::transform`, takes the view that contains the elements divisible by three and provides a view of the square of those elements.
47+
The first range adaptor, `std::views::filter`, provides a view that contains the elements from `input` that are divisible by three. The other range adaptor, `std::views::transform`, takes the view that contains the elements divisible by three and provides a view of the square of those elements.
4848

49-
When a range adapter produces a view, it doesn't incur the cost of transforming every element in the range to produce that view. The cost to process an element in the view is paid only when you access that element.
49+
When a range adaptor produces a view, it doesn't incur the cost of transforming every element in the range to produce that view. The cost to process an element in the view is paid only when you access that element.
5050

5151
Creating a view only prepares to do work in the future. In the previous example, creating the view doesn't result in finding all the elements divisible by three. It also doesn't square the elements that it finds. That work happens only when you access an element in the view.
5252

@@ -77,17 +77,17 @@ int main()
7777
}
7878
```
7979

80-
Range adapters come in many forms. For example, there are range adapters that allow you to produce a view by:
80+
Range adaptors come in many forms. For example, there are range adaptors that allow you to produce a view by:
8181

8282
- Filtering another range based on a predicate (`view::filter`).
8383
- Transforming the elements in a range (`view::transform`).
8484
- Splitting a range (`view::split`).
8585

86-
Range adapters can be chained together (composed). That's where the power and flexibility of ranges are most apparent. Composing range adapters allows you to overcome a core problem with the previous Standard Template Library (STL) algorithms, which is that they aren't easy to chain together.
86+
Range adaptors can be chained together (composed). That's where the power and flexibility of ranges are most apparent. Composing range adaptors allows you to overcome a core problem with the previous Standard Template Library (STL) algorithms, which is that they aren't easy to chain together.
8787

88-
The following range adapters are available in the `std::views` namespace. The `std::views` namespace is a convenience alias for `std::ranges::views`.
88+
The following range adaptors are available in the `std::views` namespace. The `std::views` namespace is a convenience alias for `std::ranges::views`.
8989

90-
| Range adapter | Description |
90+
| Range adaptor | Description |
9191
|--|--|
9292
| [`all`](#all)<sup>C++20</sup> | Create a view that refers to a range and its elements. |
9393
| [`common`](#common)<sup>C++20</sup> | Create a view that has the same iterator and sentinel types from a range that doesn't. |
@@ -107,15 +107,15 @@ The following range adapters are available in the `std::views` namespace. The `s
107107
| [`transform`](#transform)<sup>C++20</sup> | Create a view of transformed elements from another view. |
108108
| [`values`](#values)<sup>C++20</sup> | Create a view of the second index into each tuple-like value in a collection. |
109109

110-
In the previous table, a range adapter is typically described as taking a range and producing a view. To be precise, range adapters have a range argument that accepts one of the following:
110+
In the previous table, a range adaptor is typically described as taking a range and producing a view. To be precise, range adaptors have a range argument that accepts one of the following:
111111

112112
- The `cv-unqualified` type models `view`, and the argument is an rvalue or is copyable.
113113
- When you pass the argument as an lvalue, it must model `range` and live as long as the view.
114114
- When you pass the argument as an rvalue, such as when calling [`owning_view`](owning-view-class.md), it must model `range` and `movable`.
115115

116-
Range adapter functions are typically [function objects](https://eel.is/c++draft/function.objects), which look like function calls and enforce constraints on the types that can be passed.
116+
Range adaptor functions are typically [function objects](https://eel.is/c++draft/function.objects), which look like function calls and enforce constraints on the types that can be passed.
117117

118-
You can pass range adapters and the result of pipe operations (`|`) to code that expects function objects. In the following example, the view that the `split` range adapter creates is passed to the `transform` range adapter as if by a function call, because the `transform` range adapter is a function object.
118+
You can pass range adaptors and the result of pipe operations (`|`) to code that expects function objects. In the following example, the view that the `split` range adaptor creates is passed to the `transform` range adaptor as if by a function call, because the `transform` range adaptor is a function object.
119119

120120
```cpp
121121
std::map<int, string> x = {{0, "Hello, world"}, {42, "Goodbye, world"}};
@@ -151,7 +151,7 @@ Use `std::views::all_t<decltype((rg))>` to get the type of the returned view.
151151

152152
### Remarks
153153

154-
This range adapter is the best way to convert a range into a view. One reason to create a view from a range is to pass it by value at low cost, if passing the range by value could be expensive.
154+
This range adaptor is the best way to convert a range into a view. One reason to create a view from a range is to pass it by value at low cost, if passing the range by value could be expensive.
155155

156156
Getting a view for a range is a useful alternative to passing a heavyweight range by value because views are inexpensive to create, copy, and destroy. A possible exception is `owning_view`, which is a view that owns the underlying range.
157157

@@ -209,7 +209,7 @@ The range to create the view from.
209209
210210
### Remarks
211211
212-
When an API requires the begin iterator and end sentinel to have the same type, and the view that you're using doesn't meet that requirement (or you don't know if it does), use this range adapter to create a `common_view`. It guarantees that the type of the begin iterator and the type of the end sentinel are the same.
212+
When an API requires the begin iterator and end sentinel to have the same type, and the view that you're using doesn't meet that requirement (or you don't know if it does), use this range adaptor to create a `common_view`. It guarantees that the type of the begin iterator and the type of the end sentinel are the same.
213213
214214
### Example: `common`
215215
@@ -396,7 +396,7 @@ Create a view that contains the elements of a range that remain after the leadin
396396
constexpr ranges::view auto drop_while(R&& rg, P&& predicate);
397397

398398
2) template<class P>
399-
constexpr /*range adapter closure*/ drop_while(P&& predicate);
399+
constexpr /*range adaptor closure*/ drop_while(P&& predicate);
400400
```
401401
402402
### Parameters
@@ -574,7 +574,7 @@ Create a view that contains the elements of a range that match the specified con
574574
constexpr ranges::view auto filter(R&& rg, P&& predicate);
575575

576576
2) template<class P>
577-
constexpr /*range adapter closure*/ filter(P&& predicate);
577+
constexpr /*range adaptor closure*/ filter(P&& predicate);
578578
```
579579
580580
### Parameters
@@ -686,7 +686,7 @@ void print(auto&& v)
686686
687687
int main()
688688
{
689-
// create an iota view with its range adapter (preferred)
689+
// create an iota view with its range adaptor (preferred)
690690
print(std::views::iota(0, 5)); // outputs 0 1 2 3 4
691691
692692
// create an iota_view class directly
@@ -722,7 +722,7 @@ The type of the elements to extract from the stream.
722722
A [`basic_istream_view`](basic-istream-view-class.md).
723723

724724

725-
This range adapter is equivalent to `ranges::basic_istream_view<Val, typename U::char_type, typename U::traits_type>(str)`, where `U` is the type of `str`.
725+
This range adaptor is equivalent to `ranges::basic_istream_view<Val, typename U::char_type, typename U::traits_type>(str)`, where `U` is the type of `str`.
726726

727727
### Example: `istream`
728728

@@ -755,7 +755,7 @@ Create a view that combines all the elements of multiple ranges into a single vi
755755
1) template <ranges::viewable_range R>
756756
[[nodiscard]] constexpr ranges::view auto join(R&& rg) const noexcept;
757757

758-
2) inline constexpr /*range adapter closure*/ join();
758+
2) inline constexpr /*range adaptor closure*/ join();
759759
```
760760
761761
### Parameters
@@ -864,7 +864,7 @@ int main()
864864
{"Windows 2000", 2000}
865865
};
866866
867-
// Another way to call the range adapter is by using '|'
867+
// Another way to call the range adaptor is by using '|'
868868
for (std::string version : windows | std::views::keys)
869869
{
870870
std::cout << version << ' '; // Windows 1.0 Windows 2.0 Windows 3.0 ...
@@ -886,7 +886,7 @@ Split a range into subranges based on a delimiter. The delimiter can be a single
886886
constexpr view auto lazy_split(R&& rg, Pattern&& delimiter);
887887

888888
2) template<class Pattern>
889-
constexpr /*range adapter closure*/ lazy_split(Pattern&& delimiter);
889+
constexpr /*range adaptor closure*/ lazy_split(Pattern&& delimiter);
890890
```
891891
892892
### Parameters
@@ -911,7 +911,7 @@ A [`lazy_split_view`](lazy-split-view-class.md) that contains one or more subran
911911
912912
The delimiter isn't part of the result. For example, if you split the range `1,2,3` on the value `2`, you get two subranges: `1` and `3`.
913913
914-
A related adapter is [`split`](#split). The primary differences between `split_view` and `lazy_split_view` are:
914+
A related adaptor is [`split`](#split). The primary differences between `split_view` and `lazy_split_view` are:
915915
916916
| View | Can split a `const` range | Range iterator |
917917
|--|--|--|
@@ -976,7 +976,7 @@ Create a view of the elements of a range in reverse order.
976976
1) template<viewable_range R>
977977
constexpr ranges::view auto reverse(R&& rg);
978978

979-
2) inline constexpr /*range adapter closure*/ reverse();
979+
2) inline constexpr /*range adaptor closure*/ reverse();
980980
```
981981
982982
### Parameters
@@ -1018,7 +1018,7 @@ int main()
10181018
}
10191019
std::cout << '\n';
10201020
1021-
// using the range adapter without using the pipe syntax
1021+
// using the range adaptor without using the pipe syntax
10221022
auto rv2 = std::views::reverse(v);
10231023
for (auto &&e : rv2) // outputs 6 5 -4 3 2 1 0
10241024
{
@@ -1090,7 +1090,7 @@ Split a view into subranges based on a delimiter. The delimiter can be a single
10901090
constexpr view auto split(R&& rg, Pattern&& delimiter);
10911091

10921092
2) template<class Pattern>
1093-
constexpr /*range adapter closure*/ split(Pattern&& delimiter);
1093+
constexpr /*range adaptor closure*/ split(Pattern&& delimiter);
10941094
```
10951095
10961096
### Parameters
@@ -1115,7 +1115,7 @@ A [`split_view`](split-view-class.md) that contains one or more subranges.
11151115
11161116
The delimiter isn't part of the result. For example, if you split the range `1,2,3` on the value `2`, you get two subranges: `1` and `3`.
11171117
1118-
A related adapter is [`lazy_split`](#lazy_split). The primary differences between `split_view` and `lazy_split_view` are:
1118+
A related adaptor is [`lazy_split`](#lazy_split). The primary differences between `split_view` and `lazy_split_view` are:
11191119
11201120
| View | Can split a `const` range | Range type |
11211121
|---|---|---|
@@ -1180,7 +1180,7 @@ Create a view that contains the specified number of elements taken from the fron
11801180
constexpr ranges::view auto take(R&& rg, ranges::range_difference_type<R> count);
11811181

11821182
2) template<class DifferenceType>
1183-
constexpr /*range adapter closure*/ take(DifferenceType&& count);
1183+
constexpr /*range adaptor closure*/ take(DifferenceType&& count);
11841184
```
11851185
11861186
### Parameters
@@ -1250,7 +1250,7 @@ Create a view that contains the leading elements of a range that match the speci
12501250
constexpr ranges::view auto take_while(R&& rg, P&& predicate);
12511251

12521252
2) template<class P>
1253-
constexpr /*range adapter closure*/ take_while(P&& predicate);
1253+
constexpr /*range adaptor closure*/ take_while(P&& predicate);
12541254
```
12551255
12561256
### Parameters
@@ -1322,7 +1322,7 @@ Create a view of elements, each of which is a transformation of an element in th
13221322
constexpr ranges::view auto transform(R&& rg, F&& fun);
13231323

13241324
2) template<class F>
1325-
constexpr /*range adapter closure*/ transform(F&& fun);
1325+
constexpr /*range adaptor closure*/ transform(F&& fun);
13261326
```
13271327
13281328
### Parameters
@@ -1451,7 +1451,7 @@ int main()
14511451
{"Windows 2000", 2000}
14521452
};
14531453
1454-
// Another way to call the range adapter by using '|'
1454+
// Another way to call the range adaptor by using '|'
14551455
// Create a values_view that contains the year from each pair
14561456
for (int years : windows | std::views::values)
14571457
{
@@ -1465,7 +1465,7 @@ int main()
14651465
1985 1987 1990 1992 1993 1995 1996 1995 1998 1985 2000
14661466
```
14671467

1468-
## Range adapter type aliases
1468+
## Range adaptor type aliases
14691469

14701470
### `all_t`
14711471

docs/standard-library/ranges.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ The result, `output`, is itself a kind of range called a *view*.
5050

5151
A view is a lightweight range. View operations--such as default construction, move construction/assignment, copy construction/assignment (if present), destruction, begin, and end--all happen in constant time regardless of the number of elements in the view.
5252

53-
Views are created by range adapters, which are discussed in the following section. For more information about the classes that implement various views, see [View classes](view-classes.md).
53+
Views are created by range adaptors, which are discussed in the following section. For more information about the classes that implement various views, see [View classes](view-classes.md).
5454

55-
How the elements in the view appear depends on the range adapter that you use to create the view. In the previous example, a range adapter takes a range and returns a view of the elements divisible by three. The underlying range is unchanged.
55+
How the elements in the view appear depends on the range adaptor that you use to create the view. In the previous example, a range adaptor takes a range and returns a view of the elements divisible by three. The underlying range is unchanged.
5656

5757
Views are composable, which is powerful. In the previous example, the view of vector elements that are divisible by three is combined with the view that squares those elements.
5858

@@ -81,15 +81,15 @@ int main()
8181
}
8282
```
8383

84-
## Range adapters
84+
## Range adaptors
8585

86-
Range adapters take a range and produce a view. Range adapters produce lazily evaluated views. That is, you don't incur the cost of transforming every element in the range to produce the view. You only pay the cost to process an element in the view when you access that element.
86+
Range adaptors take a range and produce a view. Range adaptors produce lazily evaluated views. That is, you don't incur the cost of transforming every element in the range to produce the view. You only pay the cost to process an element in the view when you access that element.
8787

88-
In the previous example, the `filter` range adapter creates a view named `input` that contains the elements that are divisible by three. The `transform` range adapter takes the view of elements divisible by three and creates a view of those elements squared.
88+
In the previous example, the `filter` range adaptor creates a view named `input` that contains the elements that are divisible by three. The `transform` range adaptor takes the view of elements divisible by three and creates a view of those elements squared.
8989

90-
Range adapters can be chained together (composed), which is the heart of the power and flexibility of ranges. Composing range adapters allows you to overcome the problem that the previous STL algorithms aren't easily composable.
90+
Range adaptors can be chained together (composed), which is the heart of the power and flexibility of ranges. Composing range adaptors allows you to overcome the problem that the previous STL algorithms aren't easily composable.
9191

92-
For more information about creating views, see [Range adapters](range-adaptors.md).
92+
For more information about creating views, see [Range adaptors](range-adaptors.md).
9393

9494
## Range algorithms
9595

@@ -134,5 +134,5 @@ The range concepts mirror the hierarchy of iterator categories. The following ta
134134
## See also
135135

136136
[Range functions](range-functions.md)\
137-
[Range adapters](range-adaptors.md)\
137+
[Range adaptors](range-adaptors.md)\
138138
[Header files reference](../standard-library/cpp-standard-library-header-files.md)

0 commit comments

Comments
 (0)