From 2579a2ef480bb2f85f050d1344b503b8cd899575 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 26 Jul 2015 13:14:56 +0300 Subject: Add macro constexpr2. Depend on compiler and version it can be constexpr or empty line. This need for compilers with advanced constexpr support. --- src/utils/mathutils.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/utils') diff --git a/src/utils/mathutils.h b/src/utils/mathutils.h index b8dcdef9b..37de98b54 100644 --- a/src/utils/mathutils.h +++ b/src/utils/mathutils.h @@ -119,13 +119,13 @@ static constexpr const uint8_t square_roots[1000] = }; inline uint16_t getCrc16(const std::string &str) A_WARN_UNUSED; -constexpr inline float fastInvSqrt(float x) A_WARN_UNUSED; -constexpr inline float fastSqrt(const float x) A_WARN_UNUSED; +constexpr2 inline float fastInvSqrt(float x) A_WARN_UNUSED; +constexpr2 inline float fastSqrt(const float x) A_WARN_UNUSED; constexpr inline float weightedAverage(const float n1, const float n2, const float w) A_WARN_UNUSED; constexpr inline int roundDouble(const double v) A_WARN_UNUSED; -constexpr inline int powerOfTwo(const unsigned int input) A_WARN_UNUSED; -constexpr inline int fastSqrtInt(const unsigned int n) A_WARN_UNUSED; +constexpr2 inline int powerOfTwo(const unsigned int input) A_WARN_UNUSED; +constexpr2 inline int fastSqrtInt(const unsigned int n) A_WARN_UNUSED; inline uint16_t getCrc16(const std::string &str) { @@ -151,7 +151,7 @@ inline uint16_t getCrc16(const std::string &str) * Unfortunately the original creator of this function seems to be unknown. */ -constexpr inline float fastInvSqrt(float x) +constexpr2 inline float fastInvSqrt(float x) { union { int i; float x; } tmp = {0U}; const float xhalf = 0.5F * x; @@ -162,7 +162,7 @@ constexpr inline float fastInvSqrt(float x) return x; } -constexpr inline float fastSqrt(const float x) +constexpr2 inline float fastSqrt(const float x) { return 1.0F / fastInvSqrt(x); } @@ -178,7 +178,7 @@ constexpr inline int roundDouble(const double v) return (v > 0.0) ? static_cast(v + 0.5) : static_cast(v - 0.5); } -constexpr inline int powerOfTwo(const unsigned int input) +constexpr2 inline int powerOfTwo(const unsigned int input) { unsigned int value = 1; while (value < input) @@ -186,7 +186,7 @@ constexpr inline int powerOfTwo(const unsigned int input) return value; } -constexpr inline int fastSqrtInt(const unsigned int n) +constexpr2 inline int fastSqrtInt(const unsigned int n) { if (n < 1000) return static_cast(square_roots[n]); -- cgit v1.2.3-70-g09d2