Consider the code below:
#include
struct T
{
T() = delete;
};
int main()
{
std::array a;
a.size();
}
<
Since there's no elements, no constructor of T should be called.
Does non-default-constructible T preventstd::array
from being default-constructible?
The standard doesn't specify what layout std::array
should have for us to answer that. The zero sized array specialization is only said to behave as follows:
[array.zero]
1 array shall provide support for the special case N == 0.
2 In the case that N == 0, begin() == end() == unique value. The return value of data() is unspecified.
3 The effect of calling front() or back() for a zero-sized array is undefined.
4 Member function swap() shall have a non-throwing exception specification.
The behavior you note is most probably due to differences in implementation alone.