There is std::array<T, N>::size()
, but it's non-static, so it requires an instance of std::array
. Is there a way to get the value it returns (which is the N
of std::array<T, N>
) without having to construct an instance of the array? For a normal array, I could have used sizeof
, but I see no guarantee that sizeof(std::array<T, N>) == N * sizeof(T)
be true.
There's std::tuple_size<std::array>
.
static_assert(std::tuple_size<std::array<int, 5>>::value == 5);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With