How to get the number of elements in std::array<T, N> without having to create its instance?

Viewed 363

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.

1 Answers
Related