Is the following a valid C++ code, and why not?
std::array a1;
std::array a2;
It doesn\'t compile
std::array::size
is actually required to be constexpr
per § 23.3.2.1 of the C++11 standard:
23.3.2.4 array::size [array.size]
template constexpr size_type array::size() noexcept;
Returns: N
I'm guessing this just slipped past whoever implemented it in GCC.
After testing, this works:
std::array a1;
std::array a2;
This may actually have something to do with std::string
not being a valid constexpr
type to make compile-time instances of, whereas int
is.