Skip to content

Commit 426ce8a

Browse files
authored
[ranges] Tweak some examples (#5791)
Removes redundant `std::` qualifications and uses `views::meow` instead of `meow_view`.
1 parent b8707d9 commit 426ce8a

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

source/ranges.tex

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2201,11 +2201,11 @@
22012201
\begin{example}
22022202
\begin{codeblock}
22032203
template<bool YieldElements>
2204-
std::generator<any> f(std::ranges::@\libconcept{input_range}@ auto&& r) {
2204+
generator<any> f(ranges::@\libconcept{input_range}@ auto&& r) {
22052205
if constexpr (YieldElements)
2206-
co_yield std::ranges::elements_of(r); // yield each element of \tcode{r}
2206+
co_yield ranges::elements_of(r); // yield each element of \tcode{r}
22072207
else
2208-
co_yield r; // yield \tcode{r} as a single value
2208+
co_yield r; // yield \tcode{r} as a single value
22092209
}
22102210
\end{codeblock}
22112211
\end{example}
@@ -3825,7 +3825,7 @@
38253825
\begin{example}
38263826
\begin{codeblock}
38273827
auto ints = istringstream{"0 1 2 3 4"};
3828-
ranges::copy(ranges::istream_view<int>(ints), ostream_iterator<int>{cout, "-"});
3828+
ranges::copy(views::istream<int>(ints), ostream_iterator<int>{cout, "-"});
38293829
// prints \tcode{0-1-2-3-4-}
38303830
\end{codeblock}
38313831
\end{example}
@@ -5919,7 +5919,7 @@
59195919
\begin{codeblock}
59205920
auto input = istringstream{"0 1 2 3 4 5 6 7 8 9"};
59215921
auto small = [](const auto x) noexcept { return x < 5; };
5922-
auto small_ints = istream_view<int>(input) | views::take_while(small);
5922+
auto small_ints = views::istream<int>(input) | views::take_while(small);
59235923
for (const auto i : small_ints) {
59245924
cout << i << ' '; // prints \tcode{0 1 2 3 4}
59255925
}
@@ -14251,9 +14251,9 @@
1425114251
\pnum
1425214252
\begin{example}
1425314253
\begin{codeblock}
14254-
std::vector<int> v { 0, 1, 2 };
14254+
vector<int> v { 0, 1, 2 };
1425514255
for (auto&& [a, b, c] : views::cartesian_product(v, v, v)) {
14256-
std::cout << a << ' ' << b << ' ' << c << '\n';
14256+
cout << a << ' ' << b << ' ' << c << '\n';
1425714257
}
1425814258
// The above prints
1425914259
// \tcode{0 0 0}
@@ -15003,14 +15003,14 @@
1500315003
is successively produced as an element of the sequence.
1500415004
\begin{example}
1500515005
\begin{codeblock}
15006-
std::generator<int> ints(int start = 0) {
15006+
generator<int> ints(int start = 0) {
1500715007
while (true)
1500815008
co_yield start++;
1500915009
}
1501015010

1501115011
void f() {
15012-
for (auto i : ints() | std::views::take(3))
15013-
std::cout << i << ' '; // prints \tcode{0 1 2}
15012+
for (auto i : ints() | views::take(3))
15013+
cout << i << ' '; // prints \tcode{0 1 2}
1501415014
}
1501515015
\end{codeblock}
1501615016
\end{example}

0 commit comments

Comments
 (0)