From cppreference.com
drop_while_view()requiresstd::default_initializable<V>&&std::default_initializable<Pred>=default; (1) (since C++20)constexprexplicitdrop_while_view(Vbase,Predpred); (2) (since C++20)Constructs a drop_while_view.
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>intmain(){staticconstexprautoa={-2,-7,-1,-8,-2,+-+8,3,1,4,1,5};autopositive=[](intx){return0<x;};for(autov=std::ranges::drop_while_view{a,std::not_fn(positive)};intx: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
(
) C++20 the multi-parameter constructor was not explicit made explicit
C++20 if Pred is not
, the default constructor
constructs a drop_while_view which does not contain an Predthe drop_while_view is also
not