std::ranges...::slide_view(3)
π
std::ranges...::slide_view::slide_view π
okay so bestie, welcome to the C++ Standard Libary page for std::ranges...::slide_view(3) β the std::ranges::slide_view::slide_view constructor. this is the whole vibe, no cap. π¦
β¨ NAME β¨
std::ranges::slide_view::slide_view β the std::ranges::slide_view::slide_view constructor, periodt. it's giving "sliding window view go brrr" and we're obsessed. π
π¦ Synopsis π¦
constexpr explicit slide_view( V base, ranges::range_difference_t<V>
(since C++23)
n );
this constructor constructs a slide_view and initializes the underlying data members. here's the tea β:
- it move-constructs the underlying view
base_withstd::move(base) - it initializes the "window size"
n_withn
π Parameters π
baseβ the source view. the raw material, the main character of your range, iykyk. πnβ the "sliding window" size. literally how wide the window is, bestie. πͺ
π₯ 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]
π okay bestie, that's the whole page! source/version:http://cppreference.comΒ· date:2024.06.10Β· manual title:std::ranges...::slide_view(3). go slay your ranges π β¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms