Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is/was the purpose of std::make_array? Is it still needed in C++20?

I just found that in library fundamentals TS v2 there is a make_array (std::experimental::make_array) template that allows to deduce an arrays type from its parameters. I guess the main intention was to enable usage of auto similar to the example on cppreference:

auto x = std::experimental::make_array(1,2,3,4,5);

Is there a different motivation that I don't see?

With the new type deduction facilites in C++20, can one still expect that make_array will make it into the standard one day, or is it already obsolete?

like image 441
463035818_is_not_a_number Avatar asked Dec 11 '19 15:12

463035818_is_not_a_number


1 Answers

make_array(1,'2',3,4,5) or make_array<float>(1,'2',3,4,5) would be valid whereas Class Template Argument Deduction (CTAD) of std::array only allows same type.

like image 93
Jarod42 Avatar answered Nov 03 '22 00:11

Jarod42