std::ranges::drop_while_view<V,Pred>::drop_while_view
From cppreference.com
< cpp | ranges | drop while view
drop_while_view() = default; |
(1) | (since C++20) |
constexpr drop_while_view( V base, Pred pred ); |
(2) | (since C++20) |
Constructs a drop_while_view
.
1) Default constructor. Value-initializes the underlying view and the predicate. If
Pred
is not default_initializable, the drop_while_view
does not hold a predicate, and subsequent use of the predicate (e.g. call of begin
) is undefined behavior.2) Move constructs the underlying view from
base
and the predicate from pred
.Parameters
base | - | underlying view |
pred | - | predicate |
Example
Run this code
#include <array> #include <iostream> #include <ranges> int main() { constexpr std::array data{ 0, -1, -2, 3, 1, 4, 1, 5, }; auto view = std::ranges::drop_while_view{ data, [](int x) { return x <= 0; } }; for (int x: view) { std::cout << x << ' '; } std::cout << '\n'; }
Output:
3 1 4 1 5