std::ranges::elements_view<V,N>::elements_view
From cppreference.com
< cpp | ranges | elements view
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Ranges library
(C++23)(C++23)
(C++26)(C++26)
(C++23)(C++23)
(C++26)(C++26)
(C++26)(C++26)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)
(C++23)(C++23)
(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
std::ranges::elements_view
elements_view::elements_view
(C++26)
elements_view() requires std::default_initializable <V> = default;
(1)
(since C++20)
constexpr explicit elements_view( V base );
(2)
(since C++20)
Constructs an elements_view
.
1) Default constructor. Value-initializes the underlying view
base_
. After construction, base()
returns a copy of V().2) Initializes the underlying view
base_
with std::move(base).[edit] Parameters
base
-
the underlying view
[edit] Example
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:
1 2 A B α β