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

FreeBSD Manual Pages

  
 
  

home | help
deductiongu...rstd::array(3)  C++ Standard Libary deductiongu...rstd::array(3)

NAME
       deductionguidesforstd::array - deductionguidesforstd::array

Synopsis
	  Defined in header <array>
	  template< class T, class... U	>

	  array( T, U... )		    (since C++17)

	    -> array<T,	1 + sizeof...(U)>;

	  One deduction	guide is provided for std::array to provide an equiva-
       lent of
	  std::experimental::make_array	 for construction of std::array	from a
       variadic
	  parameter pack.

	  The program is ill-formed if (std::is_same_v<T, U> &&	 ...)  is  not
       true. Note that
	  (std::is_same_v<T, U>	&& ...)	is true	when sizeof...(U) is zero.

Example
       // Run this code

	#include <array>
	#include <cassert>

	int main()
	{
	    int	const x	= 10;
	    std::array a{1, 2, 3, 5, x}; // OK,	creates	std::array<int,	5>
	    assert(a.back() == x);

	//   std::array	 b{1,  2u}; // Error, all arguments must have the same
       type

	//  std::array<short> c{3, 2, 1}; // Error, wrong number  of  template
       args
	    std::array	c(std::to_array<short>({3,  2, 1})); //	C++20 alterna-
       tive,
							   // creates std::ar-
       ray<short, 3>
	}

http://cppreference.com		  2024.06.10	  deductiongu...rstd::array(3)

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

home | help