Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
std::ranges...lements_view(3) C++ Standard Libarystd::ranges...lements_view(3)

NAME
       std::ranges::elements_view::elements_view      -	     std::ranges::ele-
       ments_view::elements_view

Synopsis
	  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. After
       construction,
	  base() returns a copy	of V().
	  2) Initializes the underlying	view with std::move(base).

Parameters
	  base - the underlying	view

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

http://cppreference.com		  2024.06.10	 std::ranges...lements_view(3)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=std::ranges::elements_view::elements_view&sektion=3&manpath=FreeBSD+Ports+15.1.quarterly>

home | help