Skip to content

Commit 77d389f

Browse files
timsong-cpptkoeppe
authored andcommitted
[ranges] Use views::meow in examples instead of meow_view
1 parent 66b5d5e commit 77d389f

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

source/ranges.tex

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1925,7 +1925,7 @@
19251925
\pnum
19261926
\begin{example}
19271927
\begin{codeblock}
1928-
empty_view<int> e;
1928+
auto e = views::empty<int>;
19291929
static_assert(ranges::empty(e));
19301930
static_assert(0 == e.size());
19311931
\end{codeblock}
@@ -1968,8 +1968,7 @@
19681968
\pnum
19691969
\begin{example}
19701970
\begin{codeblock}
1971-
single_view s{4};
1972-
for (int i : s)
1971+
for (int i : views::single(4))
19731972
cout << i; // prints \tcode{4}
19741973
\end{codeblock}
19751974
\end{example}
@@ -2109,7 +2108,7 @@
21092108
\pnum
21102109
\begin{example}
21112110
\begin{codeblock}
2112-
for (int i : iota_view{1, 10})
2111+
for (int i : views::iota(1, 10))
21132112
cout << i << ' '; // prints: 1 2 3 4 5 6 7 8 9
21142113
\end{codeblock}
21152114
\end{example}
@@ -3353,7 +3352,7 @@
33533352
\begin{example}
33543353
\begin{codeblock}
33553354
vector<int> is{ 0, 1, 2, 3, 4, 5, 6 };
3356-
filter_view evens{is, [](int i) { return 0 == i % 2; }};
3355+
auto evens = views::filter(is, [](int i) { return 0 == i % 2; });
33573356
for (int i : evens)
33583357
cout << i << ' '; // prints: 0 2 4 6
33593358
\end{codeblock}
@@ -3774,7 +3773,7 @@
37743773
\begin{example}
37753774
\begin{codeblock}
37763775
vector<int> is{ 0, 1, 2, 3, 4 };
3777-
transform_view squares{is, [](int i) { return i * i; }};
3776+
auto squares = views::transform(is, [](int i) { return i * i; });
37783777
for (int i : squares)
37793778
cout << i << ' '; // prints: 0 1 4 9 16
37803779
\end{codeblock}
@@ -4487,8 +4486,7 @@
44874486
\begin{example}
44884487
\begin{codeblock}
44894488
vector<int> is{0,1,2,3,4,5,6,7,8,9};
4490-
take_view few{is, 5};
4491-
for (int i : few)
4489+
for (int i : is | views::take(5))
44924490
cout << i << ' '; // prints: 0 1 2 3 4
44934491
\end{codeblock}
44944492
\end{example}
@@ -4898,8 +4896,7 @@
48984896
\begin{example}
48994897
\begin{codeblock}
49004898
auto ints = views::iota(0) | views::take(10);
4901-
auto latter_half = drop_view{ints, 5};
4902-
for (auto i : latter_half) {
4899+
for (auto i : ints | views::drop(5)) {
49034900
cout << i << ' '; // prints \tcode{5 6 7 8 9}
49044901
}
49054902
\end{codeblock}
@@ -5027,7 +5024,7 @@
50275024
\begin{codeblock}
50285025
constexpr auto source = " \t \t \t hello there";
50295026
auto is_invisible = [](const auto x) { return x == ' ' || x == '\t'; };
5030-
auto skip_ws = drop_while_view{source, is_invisible};
5027+
auto skip_ws = views::drop_while(source, is_invisible);
50315028
for (auto c : skip_ws) {
50325029
cout << c; // prints \tcode{hello there} with no leading space
50335030
}
@@ -5140,8 +5137,7 @@
51405137
\begin{example}
51415138
\begin{codeblock}
51425139
vector<string> ss{"hello", " ", "world", "!"};
5143-
join_view greeting{ss};
5144-
for (char ch : greeting)
5140+
for (char ch : ss | views::join)
51455141
cout << ch; // prints: \tcode{hello world!}
51465142
\end{codeblock}
51475143
\end{example}
@@ -5626,8 +5622,7 @@
56265622
\begin{example}
56275623
\begin{codeblock}
56285624
string str{"the quick brown fox"};
5629-
lazy_split_view sentence{str, ' '};
5630-
for (auto word : sentence) {
5625+
for (auto word : str | views::lazy_split(' ')) {
56315626
for (char ch : word)
56325627
cout << ch;
56335628
cout << '*';
@@ -6533,7 +6528,7 @@
65336528

65346529
template<@\libconcept{forward_range}@ R>
65356530
void my_algo(R&& r) {
6536-
auto&& common = common_view{r};
6531+
auto&& common = views::common(r);
65376532
auto cnt = count(common.begin(), common.end());
65386533
// ...
65396534
}
@@ -6658,8 +6653,7 @@
66586653
\begin{example}
66596654
\begin{codeblock}
66606655
vector<int> is {0,1,2,3,4};
6661-
reverse_view rv {is};
6662-
for (int i : rv)
6656+
for (int i : is | views::reverse)
66636657
cout << i << ' '; // prints: 4 3 2 1 0
66646658
\end{codeblock}
66656659
\end{example}
@@ -6803,7 +6797,7 @@
68036797

68046798
\begin{example}
68056799
\begin{codeblock}
6806-
auto names = keys_view{historical_figures};
6800+
auto names = historical_figures | views::keys;
68076801
for (auto&& name : names) {
68086802
cout << name << ' '; // prints \tcode{Babbage Hamilton Lovelace Turing }
68096803
}
@@ -6817,7 +6811,7 @@
68176811
\begin{example}
68186812
\begin{codeblock}
68196813
auto is_even = [](const auto x) { return x % 2 == 0; };
6820-
cout << ranges::count_if(values_view{historical_figures}, is_even); // prints \tcode{2}
6814+
cout << ranges::count_if(historical_figures | views::values, is_even); // prints \tcode{2}
68216815
\end{codeblock}
68226816
\end{example}
68236817

0 commit comments

Comments
 (0)