Namespaces
Variants

std::ranges::adjacent_transform_view<V,F,N>::adjacent_transform_view

来自 zh.cppreference.net
 
 
范围库
范围适配器
 
 
adjacent_transform_view() = default;
(1) (自 C++23 起)
constexpr explicit adjacent_transform_view( V base, F fun );
(2) (自 C++23 起)

构造一个 adjacent_transform_view.

1) 默认构造函数。 默认初始化 底层数据成员 fun_ 和 inner_.
2) 移动构造底层数据成员: fun_ 用 std::move(fun) 以及 inner_ 用 std::move(base).

参数

base - 底层视图
fun - N元变换函数

示例

#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';
}

输出:

6 24 60