GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::experimental::make_array(3) C++ Standard Libary std::experimental::make_array(3)

std::experimental::make_array - std::experimental::make_array


Defined in header <experimental/array>
template <class D = void, class... Types>
constexpr std::array<VT /* see below */, (library fundamentals TS v2)
sizeof...(Types)> make_array(Types&&... t);


Creates a std::array whose size is equal to the number of arguments and whose
elements are initialized from the corresponding arguments. Returns std::array<VT,
sizeof...(Types)>{std::forward<Types>(t)...}


If D is void, then the deduced type VT is std::common_type_t<Types...>. Otherwise,
it is D.


If D is void and any of std::decay_t<Types>... is a specialization of
std::reference_wrapper, the program is ill-formed.


make_array is removed in Library Fundamentals TS v3 because the deduction guide for
std::array and std::to_array have been already in C++20.


namespace details {
template<class> struct is_ref_wrapper : std::false_type {};
template<class T> struct is_ref_wrapper<std::reference_wrapper<T>> : std::true_type {};


template<class T>
using not_ref_wrapper = std::negation<is_ref_wrapper<std::decay_t<T>>>;


template <class D, class...> struct return_type_helper { using type = D; };
template <class... Types>
struct return_type_helper<void, Types...> : std::common_type<Types...> {
static_assert(std::conjunction_v<not_ref_wrapper<Types>...>,
"Types cannot contain reference_wrappers when D is void");
};


template <class D, class... Types>
using return_type = std::array<typename return_type_helper<D, Types...>::type,
sizeof...(Types)>;
}


template < class D = void, class... Types>
constexpr details::return_type<D, Types...> make_array(Types&&... t) {
return {std::forward<Types>(t)... };
}

// Run this code


#include <experimental/array>
#include <iostream>
#include <type_traits>


int main()
{
auto arr = std::experimental::make_array(1, 2, 3, 4, 5);
bool is_array_of_5_ints = std::is_same<decltype(arr), std::array<int, 5>>::value;
std::cout << "Returns an array of five ints? ";
std::cout << std::boolalpha << is_array_of_5_ints << '\n';
}


Returns an array of five ints? true


to_array Creates a std::array object from a built-in array
(function template)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.