With the C++14 standard, the initialization of an std::array
can go with single braces (see http://en.cppreference.com/w/cpp/container/array):
This, however
Without the double braces, the statement is simply ambiguous. Consider the following code:
std::array, 1> a = {{ {1, 2} }};
std::array b = { {1, 2} };
Without double braces in the first definition, the compiler will treat { {1,2} }
as a scalar initialization list for array
.
You need to declare an explicit nested braced-init-list in order for the compiler to recognize that the inner list is also aggregate-initialized (vs. scalar initialized), such that it can construct an array of std::pair
.