std::ranges::drop_while_view<V,Pred>::drop_while_view
From cppreference.com
< cpp | ranges | drop while view
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Ranges library
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++26)(C++26)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)
(C++23)(C++23)
(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)
std::ranges::drop_while_view
drop_while_view::drop_while_view
drop_while_view() requires std::default_initializable <V> &&
std::default_initializable <Pred> = default;
(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
.
2) Move constructs the underlying view
base_
from base and the predicate pred_
from pred.[edit] Parameters
base
-
underlying view
pred
-
predicate
[edit] 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
[edit] 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 (P2711R1) |
C++20 | the multi-parameter constructor was not explicit | made explicit |
P2325R3 | C++20 | if Pred is not default_initializable , the default constructorconstructs a drop_while_view which does not contain an Pred
|
the drop_while_view is alsonot default_initializable
|