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
I'm going to guess here.
The initializer list for std::array
should be a list of T
(or trivially constructable to T
). So you could do
std::array,3> b { std::pair{1,11}, std::pair{2,22}, std::pair{3,33} };
but that is tediously verbose. In order to get the conversion to std::pair
you want, you need to provide an initializer list, so
std::array,3> b {
{ // element 1
{ // initialize from:
{ 1,11 } // std::initializer_list
}
},
...
};
I can't defend this further, but note that std::vector
is defined but std::array
is not. Neither is std::pair::pair( std::initializer_list?> )
defined.