Is it correct to initialize std :: array with one pair of curly braces if a zero array is needed?

Interestingly, this design:

std::array<int, 10> array { };

equivalent to this:

std::array<int, 10> array { {  } };

Well, both of them compile, and both of them give the same result:

for (auto e : array) {
        std::cout << e << ", ";
}

Of:

0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

I know that to initialize std :: array with the selected values ​​I have to use double curly braces due to aggregate initialization. But I do not know how this works with single brackets. So the question is:

Is this completely correct for initializing the structure with single curly braces in C ++ 11? (this means that all fields of the structure will be reset to zero)

Edit: As @dyp noted, my post question is more general. Suppose my question is about structures with only trivial elements.

+4
1

++ (8.5.1 )

7 , , , , (8.5.4).

(8.5.4 . # 3)

- , , .

,

std::array<int, 10> array {};

std::array<int, 10> array { {  } };

.

+2

All Articles