24 Ranges library [ranges]

24.7 Range adaptors [range.adaptors]

24.7.7 Take while view [range.take.while]

24.7.7.1 Overview [range.take.while.overview]

Given a unary predicate pred and a view r, take_Β­while_Β­view produces a view of the range [begin(r), ranges​::​find_Β­if_Β­not(r, pred)).
The name views​::​take_Β­while denotes a range adaptor object ([range.adaptor.object]).
Given subexpressions E and F, the expression views​::​take_Β­while(E, F) is expression-equivalent to take_Β­while_Β­view{E, F}.
Example
:
auto input = istringstream{"0 1 2 3 4 5 6 7 8 9"};
auto small = [](const auto x) noexcept { return x < 5; };
auto small_ints = istream_view<int>(input) | views::take_while(small);
for (const auto i : small_ints) {
  cout << i << ' ';                             // prints 0 1 2 3 4
}
auto i = 0;
input >> i;
cout << i;                                      // prints 6
β€” end example
 ]