In c++14 I have the following type:
std::tuple<int[2], int>;
How can I properly initialize it? This
std::tuple<int[2], int> a {{2,2},3};
gives me this error:
/usr/include/c++/5/tuple:108:25: error: array used as initializer
While this:
std::tuple<std::array<int,2>, int> a {{2,2},3};
works, but I want to be able to work with standard C-style arrays
std::tuple
is not an aggregate and doesn't provide a list-initializer constructor. This makes list initialization with that type impossible to use with C-arrays.
You can however use std::make_tuple
:
auto a = std::make_tuple<int[2], int>({2,2},3);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With