Checking the size of the tr1 array at compile time

I just found out that boost :: array :: static_size is not part of tr1 :: array, or at least not in my implementation (GCC 4.2.1), and I cannot find it in any tr1 documentation,

Is there any other way to perform a compile-time statement on the number of elements in the tr1 array?

eg. The following works with boost array, but not with tr1 array:

template<typename T>
void CheckArray(const T& input) {
  BOOST_STATIC_ASSERT(T::static_size >= 2);
}

I know that I can just use a boost array, but I'm curious.

If there is no way to do this, maybe someone knows why static_size was not included in tr1? Is this just a feature that was added to boost after tr1 was created?

+3
source share
1 answer

TR1 itself says it std::tuple_size<array<T, N> >::valuereturns the Nsize of the array.

+4

Source: https://habr.com/ru/post/1790358/


All Articles