Why are “double braces” needed in declaration of multi-dimensional array using stacked std::array?
问题 #include <array> using std::array; constexpr auto d1=2; constexpr auto d2=3; constexpr auto d3=4; // stacked std::array using arr_t = array<int,d1>; using arr2d_t = array<arr_t,d2>; using arr3d_t = array<arr2d_t,d3>; constexpr arr3d_t arr1 = {{ {{ {1,2}, {3,4}, {5,6} }}, {{ {1,2}, {3,4}, {5,6} }}, {{ {1,2}, {3,4}, {5,6} }}, {{ {1,2}, {3,4}, {5,6} }} }}; // built-in array using carr3d_t = int[d3][d2][d1]; constexpr carr3d_t arr2 = { { {1,2}, {3,4}, {5,6} }, { {1,2}, {3,4}, {5,6} }, { {1,2}, {3