When can outer braces be omitted in an initializer list?
问题 I\'ve got error C2078 in VC2010 when compiling the code below. struct A { int foo; double bar; }; std::array<A, 2> a1 = // error C2078: too many initializers { {0, 0.1}, {2, 3.4} }; // OK std::array<double, 2> a2 = {0.1, 2.3}; I found out that the correct syntax for a1 is std::array<A, 2> a1 = {{ {0, 0.1}, {2, 3.4} }}; The question is: why extra braces are required for a1 but not required for a2 ? Update The question seems to be not specific to std::array. Some examples: struct B { int foo[2]