table of contents
- Tumbleweed 2026.11.13-1.1
- Leap-16.0
- Leap-15.6
| std::ranges::drop_while_view::drop_while_view(3) | C++ Standard Libary | std::ranges::drop_while_view::drop_while_view(3) |
NAME¶
std::ranges::drop_while_view::drop_while_view - std::ranges::drop_while_view::drop_while_view
Synopsis¶
drop_while_view() requires std::default_initializable<V> && (1) (since C++20) std::default_initializable<Pred> = default; constexpr explicit drop_while_view( V base, Pred pred ); (2) (since C++20)
Constructs a drop_while_view.
1) Default constructor. Value-initializes the underlying view base_ and the predicate pred_. 2) Move constructs the underlying view base_ from base and the predicate pred_ from pred.
Parameters¶
base - underlying view pred - predicate
Example¶
// Run this code
#include <functional> #include <iostream> #include <ranges>
int main() {
static constexpr auto a = {-2, -7, -1, -8, -2, +-+8, 3, 1, 4, 1, 5};
auto positive = [](int x) { return 0 < x; };
for (auto v = std::ranges::drop_while_view{a, std::not_fn(positive)}; int x :
v)
std::cout << x << ' ';
std::cout << '\n'; }
Output:¶
3 1 4 1 5
Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR Applied to Behavior as published Correct behavior LWG 3714 C++20 the
multi-parameter constructor was not made explicit (P2711R1) explicit
if Pred is not default_initializable, the P2325R3 C++20 default constructor
the drop_while_view is also
constructs a drop_while_view which does not default_initializable
not contain an Pred
| 2026.11.10 | http://cppreference.com |