A std::array<T>
is essentially a C-style array wrapped in a struct
. The initialization of struct
s requires braces, and the initialization of arrays requires braces as well. So I need two pairs of braces:
std::array<int, 5> a = {{1, 2, 3, 4, 5}};
But most of the example code I have seen only uses one pair of braces:
std::array<int, 5> b = {1, 2, 3, 4, 5};
How come this is allowed, and does it have any benefits or drawbacks compared to the first approch?
See Question&Answers more detail:os