From Jason Turner

[range.take.while.overview]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpe71eg_n1/{from.md → to.md} +27 -0
tmp/tmpe71eg_n1/{from.md → to.md} RENAMED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### Overview <a id="range.take.while.overview">[[range.take.while.overview]]</a>
2
+
3
+ Given a unary predicate `pred` and a `view` `r`, `take_while_view`
4
+ produces a `view` of the range \[`begin(r)`,
5
+ `ranges::find_if_not(r, pred)`).
6
+
7
+ The name `views::take_while` denotes a range adaptor object
8
+ [[range.adaptor.object]]. Given subexpressions `E` and `F`, the
9
+ expression `views::take_while(E, F)` is expression-equivalent to
10
+ `take_while_view{E, F}`.
11
+
12
+ [*Example 1*:
13
+
14
+ ``` cpp
15
+ auto input = istringstream{"0 1 2 3 4 5 6 7 8 9"};
16
+ auto small = [](const auto x) noexcept { return x < 5; };
17
+ auto small_ints = istream_view<int>(input) | views::take_while(small);
18
+ for (const auto i : small_ints) {
19
+ cout << i << ' '; // prints 0 1 2 3 4
20
+ }
21
+ auto i = 0;
22
+ input >> i;
23
+ cout << i; // prints 6
24
+ ```
25
+
26
+ — *end example*]
27
+