Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::ranges::chunk_view<V>::chunk_view

      From cppreference.com
      <cpp‎ |ranges‎ |chunk view
       
       
      Ranges library
      Range adaptors
       
      std::ranges::chunk_view
      Member functions
      chunk_view::chunk_view
      Classes forinput_ranges
      Deduction guides
      outer-iterator
      outer-iterator::value_type
      inner-iterator
       
      constexprexplicit chunk_view( V base,ranges::range_difference_t<V> n);
      (since C++23)

      Constructs achunk_view, initializing the underlying data members:

      • move constructs thebase_ withstd::move(base),
      • initializes the "chunk size"n_ withn.

      In addition, ifV models exactly theinput_range, the constructor initializes the following exposition-only data members:

      The behavior is undefined ifn is less than or equal to0.

      [edit]Parameters

      base - the adapted view
      n - the chunk size

      [edit]Example

      Run this code
      #include <algorithm>#include <iostream>#include <ranges> int main(){auto i= std::views::iota(0,10);auto w= std::ranges::chunk_view(i,4);     std::ranges::for_each(w,[](autoconst v){for(auto e: v)std::cout<< e<<' ';std::cout<<'\n';});}

      Output:

      0 1 2 34 5 6 78 9
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/ranges/chunk_view/chunk_view&oldid=181232"

      [8]ページ先頭

      ©2009-2026 Movatter.jp