Nested aggregate initialization of std::array [duplicate]
问题 This question already has an answer here : When can outer braces be omitted in an initializer list? (1 answer) Closed 2 years ago . I wonder, why declaration of std_arr in the following code generates an error, while c_arr compiles well: struct S { int a, b; }; S c_arr[] = {{1, 2}, {3, 4}}; // OK std::array<S, 2> std_arr = {{1, 2}, {3, 4}}; // Error: too many initializers Both std::array and S are aggregates. From aggregate initialization on cppreference.com: If the initializer clause is a