std::ranges...lements_view(3)
bestie, welcome to std::ranges...lements_view(3) from the C++ Standard Libary (that spelling is literally in the header, I'm not doing a bits, okay π). This whole page is about std::ranges::elements_view::elements_view, and it's giving very constructor with main character energy π
π NAME π
std::ranges::elements_view::elements_view β yes, the name said it twice, and honestly? periodt. It's std::ranges::elements_view::elements_view π«Ά
β¨ Synopsis β¨
okay so here's the synopsis, copied with love and zero cap:
elements_view() requires std::default_initializable<V> = default; (1)
(since C++20)
constexpr explicit elements_view( V base ); (2)
(since C++20)
This constructs an elements_view π¦
- Default constructor β
elements_view() requires std::default_initializable<V> = default;(since C++20). It value-initializes the underlying view. After construction,base()returns a copy ofV()β¨ - The taking-a-base one β
constexpr explicit elements_view( V base );(since C++20). It initializes the underlying view withstd::move(base)π«
πΈ Parameters πΈ
baseβ the underlying view π«Ά
π Example π
bestie, run this code, it's literally right here:
// Run this code
#include <array>
#include <iostream>
#include <ranges>
#include <tuple>
void println(auto const& v)
{
for (auto const& e : v)
std::cout << e << ' ';
std::cout << '\n';
}
int main()
{
using namespace std::literals;
const std::array<std::tuple<int, char, std::string>, 2> vt
{
std::tuple{1, 'A', "Ξ±"s},
std::tuple{2, 'B', "Ξ²"s},
};
[[maybe_unused]]
auto empty = std::views::elements<0>;
println(std::views::elements<0>(vt));
println(std::views::elements<1>(vt));
println(std::views::elements<2>(vt));
}
π Output π
and the output is serving:
1 2
A B
Ξ± Ξ²
source: http://cppreference.com Β· version/date: 2024.06.10 β that's the whole page, bestie, 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