diff --git a/Source/Core/Common/Src/CommonFuncs.h b/Source/Core/Common/Src/CommonFuncs.h index 284302d70d..7f62684efb 100644 --- a/Source/Core/Common/Src/CommonFuncs.h +++ b/Source/Core/Common/Src/CommonFuncs.h @@ -13,16 +13,15 @@ #endif #include - -// TODO: make into function when type_traits and constexpr are available -template -struct ArraySizeImpl {}; - -template -struct ArraySizeImpl { static const std::size_t size = N; }; +#include // Will fail to compile on a non-array: -#define ArraySize(x) ArraySizeImpl::size +// TODO: make this a function when constexpr is available +template +struct ArraySizeImpl : public std::extent +{ static_assert(std::is_array::value, "is array"); }; + +#define ArraySize(x) ArraySizeImpl::value #define b2(x) ( (x) | ( (x) >> 1) ) #define b4(x) ( b2(x) | ( b2(x) >> 2) )