In N3337, I'm reading §23.3.2.1/3 it states:
An
array
satisfies all of the requirements of a container and of a reversible container (23.2), except that a default constructedarray
object is not empty and that swap does not have constant complexity.
In §23.2.1, Table 96 Container Requirements, it shows a default constructed object X u;
where the post condition is u.empty()
. Presumably then, the following:
std::array<int, 0> a;
should result with a.empty()
outputting 1
, which it does. So what does "empty" mean here?
You are looking at a border case - is a zero-sized array empty or not? Ignoring that specific question, the standard quote says that a general std::array<T,N> arr
, on default construction, does not satisfy the post-condition arr.empty()
. In fact, an std::array<T, N>
is empty()
only when N==0
. And this definition is natural as well - std::array<T,N>::size()
is a constexpr
with value N
and empty()
should be synonymous with size() == 0
.