| ||||||||||||||||||||||
| Range primitives | |||||||
| |||||||
| Range concepts | |||||||||||||||||||
| |||||||||||||||||||
| Range factories | |||||||||
| |||||||||
| Range adaptors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Helper items | |||||||||||||||||
| |||||||||||||||||
constexprconst Pred& pred()const; | (since C++20) | |
Returns a reference to the stored predicate.
If*this does not store a predicate (e.g. an exception is thrown on the assignment to*this, which copy-constructs or move-constructs aPred), the behavior is undefined.
(none)
A reference to the stored predicatepred_.
#include <array>#include <iomanip>#include <iostream>#include <ranges> int main(){constexprstd::array data{0,-1,-2,3,1,4,1,5}; auto view= std::ranges::drop_while_view{ data,[](int x){return x<=0;}}; std::cout<<std::boolalpha;for(int x: data)std::cout<<"predicate("<<std::setw(2)<< x<<") : "<< view.pred()(x)<<'\n';}
Output:
predicate( 0) : truepredicate(-1) : truepredicate(-2) : truepredicate( 3) : falsepredicate( 1) : falsepredicate( 4) : falsepredicate( 1) : falsepredicate( 5) : false