Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::ranges::slide_view<V>::slide_view

      From cppreference.com
      <cpp‎ |ranges‎ |slide view
       
       
      Ranges library
      Range adaptors
       
      std::ranges::slide_view
      Member functions
      slide_view::slide_view
      Deduction guides
      Iterator
      Member functions
      Non-member functions
      Sentinel
      Member functions
      Non-member functions
       
      constexprexplicit slide_view( V base,ranges::range_difference_t<V> n);
      (since C++23)

      Constructs aslide_view initializing the underlying data members:

      • move construct the underlying viewbase_ withstd::move(base),
      • the "window size"n_ withn.

      [edit]Parameters

      base - the source view
      n - the “sliding window” size

      [edit]Example

      Run this code
      #include <algorithm>#include <iostream>#include <ranges> int main(){constauto source={1,2,3,4}; auto slide= std::views::slide(source,3);     std::ranges::for_each(slide,[](std::ranges::viewable_rangeauto&& w){std::cout<<'['<< w[0]<<' '<< w[1]<<' '<< w[2]<<"]\n";});}

      Output:

      [1 2 3][2 3 4]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/ranges/slide_view/slide_view&oldid=181265"

      [8]ページ先頭

      ©2009-2026 Movatter.jp