std::ranges::slide_view<V>::slide_view
From cppreference.com
< cpp | ranges | slide view
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Ranges library
(C++23)(C++23)
(C++26)(C++26)
(C++23)(C++23)
(C++26)(C++26)
(C++26)(C++26)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)
(C++23)(C++23)
(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
std::ranges::slide_view
slide_view::slide_view
(C++26)
Member functions
Non-member functions
Member functions
Non-member functions
constexpr explicit slide_view( V base, ranges::range_difference_t <V> n );
(since C++23)
Constructs a slide_view
initializing the underlying data members:
[edit] Parameters
base
-
the source view
n
-
the "sliding window" size
[edit] Example
Run this code
#include <algorithm> #include <iostream> #include <ranges> int main() { const auto source = {1, 2, 3, 4}; auto slide = std::views::slide (source, 3); std::ranges::for_each (slide, [](std::ranges::viewable_range auto&& w) { std::cout << '[' << w[0] << ' ' << w[1] << ' ' << w[2] << "]\n"; }); }
Output:
[1 2 3] [2 3 4]