std::ranges...ansform_view(3)

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

✨ NAME ✨

okay bestie, welcome to the std::ranges...ansform_view(3) page from the C++ Standard Libary β€” we're here for the constructor with the iconic full name std::ranges::adjacent_transform_view::adjacent_transform_view. no cap, that's a whole mouthful πŸ’…

πŸ¦‹ Synopsis πŸ¦‹

adjacent_transform_view() = default;                         (1)
(since C++23)

constexpr explicit adjacent_transform_view( V base, F fun ); (2)
(since C++23)

Constructs an adjacent_transform_view. That's the main-character job fr fr ✨

  1. Default constructor. Default-initializes the underlying data members fun_ and inner_.
  2. Move constructs the underlying data members: fun_ with std::move(fun) and inner_ with std::move(base).

πŸ’– Parameters πŸ’–

  • base β€” the underlying view πŸ‘€
  • fun β€” the N-ary transformation function πŸ”₯

πŸ”₯ Example πŸ”₯

// Run this code

#include <algorithm>
#include <iostream>
#include <iterator>
#include <ranges>

int main()
{
    constexpr static auto v = {1, 2, 3, 4, 5};
    constexpr auto mul = [](auto... x) { return (... * x); };
    constexpr auto view = std::views::adjacent_transform<3>(v, mul);
    std::ranges::copy(view, std::ostream_iterator<int>(std::cout, " "));
    std::cout << '\n';
}

🌈 Output 🌈

6 24 60
ok but this tiny example and its lil output are sending me πŸ’…

mwah πŸ’‹ signing off from http://cppreference.com with the 2024.06.10 date stamp on std::ranges...ansform_view(3) β€” bye bestie, go construct something iconic 🫢✨

πŸ“¦ where this page comes from