| 6 | #include <memory> |
| 7 | |
| 8 | int main() |
| 9 | { |
| 10 | // #A Compiler deduces the size and type |
| 11 | const auto array = std::to_array("Hello, C++20"); |
| 12 | |
| 13 | // #B Compiler deduces the size and specify the type |
| 14 | const auto array2 = std::to_array<const char>("Hello, C++20"); |
| 15 | |
| 16 | // #C Create the array inline |
| 17 | const auto arrayFromList = std::to_array({3, 4, 5}); |
| 18 | |
| 19 | int intArray[]{3, 4, 5}; |
| 20 | // #D Move the values |
| 21 | const auto movedArray = std::to_array(std::move(intArray)); |
| 22 | } |