Skip to content

Commit ed60390

Browse files
committed
[ranges] Use views::meow in examples instead of meow_view
1 parent fb3bea8 commit ed60390

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
@@ -1892,7 +1892,7 @@
18921892
\pnum
18931893
\begin{example}
18941894
\begin{codeblock}
1895-
empty_view<int> e;
1895+
auto e = views::empty<int>;
18961896
static_assert(ranges::empty(e));
18971897
static_assert(0 == e.size());
18981898
\end{codeblock}
@@ -1935,8 +1935,7 @@
19351935
\pnum
19361936
\begin{example}
19371937
\begin{codeblock}
1938-
single_view s{4};
1939-
for (int i : s)
1938+
for (int i : views::single(4))
19401939
cout << i; // prints \tcode{4}
19411940
\end{codeblock}
19421941
\end{example}
@@ -2073,7 +2072,7 @@
20732072
\pnum
20742073
\begin{example}
20752074
\begin{codeblock}
2076-
for (int i : iota_view{1, 10})
2075+
for (int i : views::iota(1, 10))
20772076
cout << i << ' '; // prints: 1 2 3 4 5 6 7 8 9
20782077
\end{codeblock}
20792078
\end{example}
@@ -3187,7 +3186,7 @@
31873186
\begin{example}
31883187
\begin{codeblock}
31893188
vector<int> is{ 0, 1, 2, 3, 4, 5, 6 };
3190-
filter_view evens{is, [](int i) { return 0 == i % 2; }};
3189+
auto evens = views::filter(is, [](int i) { return 0 == i % 2; });
31913190
for (int i : evens)
31923191
cout << i << ' '; // prints: 0 2 4 6
31933192
\end{codeblock}
@@ -3610,7 +3609,7 @@
36103609
\begin{example}
36113610
\begin{codeblock}
36123611
vector<int> is{ 0, 1, 2, 3, 4 };
3613-
transform_view squares{is, [](int i) { return i * i; }};
3612+
auto squares = views::transform(is, [](int i) { return i * i; });
36143613
for (int i : squares)
36153614
cout << i << ' '; // prints: 0 1 4 9 16
36163615
\end{codeblock}
@@ -4340,8 +4339,7 @@
43404339
\begin{example}
43414340
\begin{codeblock}
43424341
vector<int> is{0,1,2,3,4,5,6,7,8,9};
4343-
take_view few{is, 5};
4344-
for (int i : few)
4342+
for (int i : is | views::take(5))
43454343
cout << i << ' '; // prints: 0 1 2 3 4
43464344
\end{codeblock}
43474345
\end{example}
@@ -4749,8 +4747,7 @@
47494747
\begin{example}
47504748
\begin{codeblock}
47514749
auto ints = views::iota(0) | views::take(10);
4752-
auto latter_half = drop_view{ints, 5};
4753-
for (auto i : latter_half) {
4750+
for (auto i : ints | views::drop(5)) {
47544751
cout << i << ' '; // prints \tcode{5 6 7 8 9}
47554752
}
47564753
\end{codeblock}
@@ -4878,7 +4875,7 @@
48784875
\begin{codeblock}
48794876
constexpr auto source = " \t \t \t hello there";
48804877
auto is_invisible = [](const auto x) { return x == ' ' || x == '\t'; };
4881-
auto skip_ws = drop_while_view{source, is_invisible};
4878+
auto skip_ws = views::drop_while(source, is_invisible);
48824879
for (auto c : skip_ws) {
48834880
cout << c; // prints \tcode{hello there} with no leading space
48844881
}
@@ -4991,8 +4988,7 @@
49914988
\begin{example}
49924989
\begin{codeblock}
49934990
vector<string> ss{"hello", " ", "world", "!"};
4994-
join_view greeting{ss};
4995-
for (char ch : greeting)
4991+
for (char ch : ss | views::join)
49964992
cout << ch; // prints: \tcode{hello world!}
49974993
\end{codeblock}
49984994
\end{example}
@@ -5481,8 +5477,7 @@
54815477
\begin{example}
54825478
\begin{codeblock}
54835479
string str{"the quick brown fox"};
5484-
split_view sentence{str, ' '};
5485-
for (auto word : sentence) {
5480+
for (auto word : str | views::split(' ')) {
54865481
for (char ch : word)
54875482
cout << ch;
54885483
cout << '*';
@@ -6057,7 +6052,7 @@
60576052

60586053
template<@\libconcept{forward_range}@ R>
60596054
void my_algo(R&& r) {
6060-
auto&& common = common_view{r};
6055+
auto&& common = views::common(r);
60616056
auto cnt = count(common.begin(), common.end());
60626057
// ...
60636058
}
@@ -6182,8 +6177,7 @@
61826177
\begin{example}
61836178
\begin{codeblock}
61846179
vector<int> is {0,1,2,3,4};
6185-
reverse_view rv {is};
6186-
for (int i : rv)
6180+
for (int i : is | views::reverse)
61876181
cout << i << ' '; // prints: 4 3 2 1 0
61886182
\end{codeblock}
61896183
\end{example}
@@ -6327,7 +6321,7 @@
63276321

63286322
\begin{example}
63296323
\begin{codeblock}
6330-
auto names = keys_view{historical_figures};
6324+
auto names = historical_figures | views::keys;
63316325
for (auto&& name : names) {
63326326
cout << name << ' '; // prints \tcode{Babbage Hamilton Lovelace Turing }
63336327
}
@@ -6341,7 +6335,7 @@
63416335
\begin{example}
63426336
\begin{codeblock}
63436337
auto is_even = [](const auto x) { return x % 2 == 0; };
6344-
cout << ranges::count_if(values_view{historical_figures}, is_even); // prints \tcode{2}
6338+
cout << ranges::count_if(historical_figures | views::values, is_even); // prints \tcode{2}
63456339
\end{codeblock}
63466340
\end{example}
63476341

0 commit comments

Comments
 (0)