std::ranges...djacent_view(3)
π NAME π
okay so you opened the std::ranges...djacent_view(3) page in the C++ Standard Library manual, and the NAME up top is literally std::ranges::adjacent_view::adjacent_view - std::ranges::adjacent_view::adjacent_view β yep, constructor name twice, it's giving main-character duplication π
. This page is all about the adjacent_view constructor, no cap.
β¨ Synopsis β¨
Both constructors are since C++23, bestie. Here's the exact synopsis, untouched:
adjacent_view() requires std::default_initializable<V> = default; (1)
(since C++23)
constexpr explicit adjacent_view( V base ); (2)
(since C++23)
Constructs an adjacent_view β yes, that's the whole sentence π.
- Default constructor. Value-initializes the underlying view. β¨
- Initializes the underlying view
base_withstd::move(base). π₯
πΈ Parameters πΈ
baseβ the underlying view π«Ά
π Example π
This is the whole example, copied exactly so you can run it:
// Run this code
#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 π¬
v: ABCDEF
ABCD
BCDE
CDEF
okay that's the whole page, bestie! π«Ά Cute sign-off with the footer info: source/version http://cppreference.com, date 2024.06.10, and page tag std::ranges...djacent_view(3). Mwah πβ¨
π¦ 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