Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::ranges::drop_while_view<V,Pred>::pred

      From cppreference.com
      <cpp‎ |ranges‎ |drop while view
       
       
      Ranges library
      Range adaptors
       
       
      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.

      [edit]Parameters

      (none)

      [edit]Return value

      A reference to the stored predicatepred_.

      [edit]Example

      Run this code
      #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
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/ranges/drop_while_view/pred&oldid=173581"

      [8]ページ先頭

      ©2009-2025 Movatter.jp