Skip to content

Commit 8724a98

Browse files
committed
[ranges] Use views::meow in examples instead of meow_view
1 parent fc053d1 commit 8724a98

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}
@@ -2106,7 +2105,7 @@
21062105
\pnum
21072106
\begin{example}
21082107
\begin{codeblock}
2109-
for (int i : iota_view{1, 10})
2108+
for (int i : views::iota(1, 10))
21102109
cout << i << ' '; // prints: 1 2 3 4 5 6 7 8 9
21112110
\end{codeblock}
21122111
\end{example}
@@ -3350,7 +3349,7 @@
33503349
\begin{example}
33513350
\begin{codeblock}
33523351
vector<int> is{ 0, 1, 2, 3, 4, 5, 6 };
3353-
filter_view evens{is, [](int i) { return 0 == i % 2; }};
3352+
auto evens = views::filter(is, [](int i) { return 0 == i % 2; });
33543353
for (int i : evens)
33553354
cout << i << ' '; // prints: 0 2 4 6
33563355
\end{codeblock}
@@ -3771,7 +3770,7 @@
37713770
\begin{example}
37723771
\begin{codeblock}
37733772
vector<int> is{ 0, 1, 2, 3, 4 };
3774-
transform_view squares{is, [](int i) { return i * i; }};
3773+
auto squares = views::transform(is, [](int i) { return i * i; });
37753774
for (int i : squares)
37763775
cout << i << ' '; // prints: 0 1 4 9 16
37773776
\end{codeblock}
@@ -4482,8 +4481,7 @@
44824481
\begin{example}
44834482
\begin{codeblock}
44844483
vector<int> is{0,1,2,3,4,5,6,7,8,9};
4485-
take_view few{is, 5};
4486-
for (int i : few)
4484+
for (int i : is | views::take(5))
44874485
cout << i << ' '; // prints: 0 1 2 3 4
44884486
\end{codeblock}
44894487
\end{example}
@@ -4891,8 +4889,7 @@
48914889
\begin{example}
48924890
\begin{codeblock}
48934891
auto ints = views::iota(0) | views::take(10);
4894-
auto latter_half = drop_view{ints, 5};
4895-
for (auto i : latter_half) {
4892+
for (auto i : ints | views::drop(5)) {
48964893
cout << i << ' '; // prints \tcode{5 6 7 8 9}
48974894
}
48984895
\end{codeblock}
@@ -5020,7 +5017,7 @@
50205017
\begin{codeblock}
50215018
constexpr auto source = " \t \t \t hello there";
50225019
auto is_invisible = [](const auto x) { return x == ' ' || x == '\t'; };
5023-
auto skip_ws = drop_while_view{source, is_invisible};
5020+
auto skip_ws = views::drop_while(source, is_invisible);
50245021
for (auto c : skip_ws) {
50255022
cout << c; // prints \tcode{hello there} with no leading space
50265023
}
@@ -5133,8 +5130,7 @@
51335130
\begin{example}
51345131
\begin{codeblock}
51355132
vector<string> ss{"hello", " ", "world", "!"};
5136-
join_view greeting{ss};
5137-
for (char ch : greeting)
5133+
for (char ch : ss | views::join)
51385134
cout << ch; // prints: \tcode{hello world!}
51395135
\end{codeblock}
51405136
\end{example}
@@ -5619,8 +5615,7 @@
56195615
\begin{example}
56205616
\begin{codeblock}
56215617
string str{"the quick brown fox"};
5622-
lazy_split_view sentence{str, ' '};
5623-
for (auto word : sentence) {
5618+
for (auto word : str | views::lazy_split(' ')) {
56245619
for (char ch : word)
56255620
cout << ch;
56265621
cout << '*';
@@ -6525,7 +6520,7 @@
65256520

65266521
template<@\libconcept{forward_range}@ R>
65276522
void my_algo(R&& r) {
6528-
auto&& common = common_view{r};
6523+
auto&& common = views::common(r);
65296524
auto cnt = count(common.begin(), common.end());
65306525
// ...
65316526
}
@@ -6650,8 +6645,7 @@
66506645
\begin{example}
66516646
\begin{codeblock}
66526647
vector<int> is {0,1,2,3,4};
6653-
reverse_view rv {is};
6654-
for (int i : rv)
6648+
for (int i : is | views::reverse)
66556649
cout << i << ' '; // prints: 4 3 2 1 0
66566650
\end{codeblock}
66576651
\end{example}
@@ -6795,7 +6789,7 @@
67956789

67966790
\begin{example}
67976791
\begin{codeblock}
6798-
auto names = keys_view{historical_figures};
6792+
auto names = historical_figures | views::keys;
67996793
for (auto&& name : names) {
68006794
cout << name << ' '; // prints \tcode{Babbage Hamilton Lovelace Turing }
68016795
}
@@ -6809,7 +6803,7 @@
68096803
\begin{example}
68106804
\begin{codeblock}
68116805
auto is_even = [](const auto x) { return x % 2 == 0; };
6812-
cout << ranges::count_if(values_view{historical_figures}, is_even); // prints \tcode{2}
6806+
cout << ranges::count_if(historical_figures | views::values, is_even); // prints \tcode{2}
68136807
\end{codeblock}
68146808
\end{example}
68156809

0 commit comments

Comments
 (0)