summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-07-26 13:14:56 +0300
committerAndrei Karas <akaras@inbox.ru>2015-07-26 13:14:56 +0300
commit2579a2ef480bb2f85f050d1344b503b8cd899575 (patch)
treefce75dbe37535e734d8091d7982d49b812904c30 /src
parentef9a3a6b34fea6c64bcb5bbabe08f69c32828857 (diff)
downloadmv-2579a2ef480bb2f85f050d1344b503b8cd899575.tar.gz
mv-2579a2ef480bb2f85f050d1344b503b8cd899575.tar.bz2
mv-2579a2ef480bb2f85f050d1344b503b8cd899575.tar.xz
mv-2579a2ef480bb2f85f050d1344b503b8cd899575.zip
Add macro constexpr2. Depend on compiler and version it can be constexpr or empty line.
This need for compilers with advanced constexpr support.
Diffstat (limited to 'src')
-rw-r--r--src/localconsts.h6
-rw-r--r--src/utils/mathutils.h16
2 files changed, 14 insertions, 8 deletions
diff --git a/src/localconsts.h b/src/localconsts.h
index f54ae5659..5d73f8c53 100644
--- a/src/localconsts.h
+++ b/src/localconsts.h
@@ -43,6 +43,7 @@
#define final
#define override
#define constexpr
+#define constexpr2
#define noexcept
#define A_DELETE(func)
#define A_DELETE_COPY(func)
@@ -56,6 +57,11 @@
// #define A_DELETE_COPY
#else
#define ADVGCC
+#if GCC_VERSION < 40900
+#define constexpr2
+#else
+#define constexpr2 constexpr
+#endif
#endif
#undef Z_NULL
#define Z_NULL nullptr
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<int>(v + 0.5) : static_cast<int>(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<int>(square_roots[n]);