参见英文答案 Why can’t simple initialize (with braces) 2D std::array? 1个 在C中,如何创建多维std :: array?我试过这个: std::arraystd::arrayint, 3, 3 arr = {{5, 8, 2}, {8, 3, 1}, {5, 3, 9}}; 但它不起作用.我做错
在C中,如何创建多维std :: array?我试过这个:
std::array<std::array<int, 3>, 3> arr = {{5, 8, 2}, {8, 3, 1}, {5, 3, 9}};
但它不起作用.我做错了什么,如何解决这个问题?
你需要额外的括号,直到 c++14 proposal开始.std::array<std::array<int, 3>, 3> arr = {{{5, 8, 2}, {8, 3, 1}, {5, 3, 9}}};