std::ranges...::slide_view(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’… 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_ with std::move(base)
  • it initializes the "window size" n_ with n

πŸ’– 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