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
The C++14 brace elision rule applies only to subaggregate initialization.
So for example something like this works:
std::array, 3> a{1, 11, 2, 22, 3, 33};
Here an aggregate of aggregates can be list-initialized without extra braces.
But std::pair
is not an aggregate (it has constructors), so the rule does not apply.
Which means that without the brace elision rule, std::array
, itself being an aggregate with an array inside, needs an extra set of braces in order to be list-initialized. Remember that the class template array
is implemented as:
template
struct array {
T elems[N];
};
To list-initialize it without the brace elision rule, you need an extra set of braces to get to the elems
member.