From 3f1b488a12f9dd8acdd8fa85331176fac0362afd Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 3 Sep 2015 23:39:03 -0400 Subject: CommonFuncs: Replace ArraySize define with constexpr equivalent --- Source/Core/Common/CommonFuncs.h | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'Source/Core/Common') diff --git a/Source/Core/Common/CommonFuncs.h b/Source/Core/Common/CommonFuncs.h index 8e039b6066..1eb57842cd 100644 --- a/Source/Core/Common/CommonFuncs.h +++ b/Source/Core/Common/CommonFuncs.h @@ -17,16 +17,14 @@ #include #include -#include #include "Common/CommonTypes.h" // Will fail to compile on a non-array: -// 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 +template +constexpr size_t ArraySize(T (&arr)[N]) +{ + return N; +} #define b2(x) ( (x) | ( (x) >> 1) ) #define b4(x) ( b2(x) | ( b2(x) >> 2) ) -- cgit v1.2.3