std::experimental::make_array

Header: <experimental/array>

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(t)…}.

# Declarations

template< class D = void, class... Types >
constexpr std::array<VT /* see below */, sizeof...(Types)> make_array( Types&&... t );

(library fundamentals TS v2)

# Notes

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.

# Example

#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';
}

# See also