开发者

Checking the size of a tr1 array at compile time

开发者 https://www.devze.com 2023-02-09 12:22 出处:网络
I just found out that boost::array::static_size isn\'t part of tr1::array, or at least it\'s not in my implementation (GCC 4.2.1) and I can\'t find it in any tr1 documentation.

I just found out that boost::array::static_size isn't part of tr1::array, or at least it's not in my implementation (GCC 4.2.1) and I can't find it in any tr1 documentation.

Is there another way to perform a compile-time assertion on the number of elements in a tr1 array?

e.g. The following works with a boost array but 开发者_C百科not a tr1 array:

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

I know I can just use boost's array instead, but I'm curious.

If there's no way to do it, maybe someone knows why static_size wasn't included in tr1? Is it just a feature that was added to boost after tr1 was created?


TR1 itself says that std::tuple_size<array<T, N> >::value returns N, the size of the array.

0

精彩评论

暂无评论...
验证码 换一张
取 消