std::ranges::adjacent_view<V,N>::adjacent_view - cppreference.com
From cppreference.com
|
|
(1) | (since C++23) |
|
|
(2) | (since C++23) |
Constructs an adjacent_view.
2) Initializes the underlying view base_ with std::move(base).
Parameters
| base | - | the underlying view |
Example
#include <iostream> #include <ranges> #include <string> #include <tuple> template<class... Ts> void print(std::tuple<Ts...> const& tuple) { std::apply([&](auto&& arg, auto&&... args) { std::cout << arg; ((std::cout << args), ...); }, tuple); std::cout << '\n'; } int main() { const std::string v{"ABCDEF"}; constexpr int window_size{4}; std::cout << "v: " << v << '\n'; auto view = std::views::adjacent<window_size>(v); // overload (2) for (auto const& tuple : view) print(tuple); }
Output: