简体   繁体   中英

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 amake_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?

make_array(1,'2',3,4,5)make_array<float>(1,'2',3,4,5)将是有效的,而std::array 类模板参数推导 (CTAD)只允许同类型。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM