What does it mean to have std::array<int,0>
,array of size zero?
I have gone through similar questions in SO before posting this, and all those
questions are regarding simple array type and for C language and most of them says that it is illegal. But in C++ array<int,0>
is allowed.
As per cppreference.com
There is a special case for a zero-length array (N == 0). In that case,
array.begin() == array.end()
, which is some unique value. The effect of callingfront()
orback()
on a zero-sized array is undefined.
Why isn't it defined as illegal?