diff --git a/glm/common.hpp b/glm/common.hpp index f8c21e87..06763846 100644 --- a/glm/common.hpp +++ b/glm/common.hpp @@ -30,7 +30,7 @@ namespace glm /// @see GLSL 4.20.8 specification, section 8.3 Common Functions /// @see qualifier template - GLM_FUNC_DECL GLM_CONSTEXPR_CXX11 genType abs(genType x); + GLM_FUNC_DECL GLM_CONSTEXPR_CXX14 genType abs(genType x); /// Returns x if x >= 0; otherwise, it returns -x. /// @@ -41,7 +41,7 @@ namespace glm /// @see GLSL abs man page /// @see GLSL 4.20.8 specification, section 8.3 Common Functions template - GLM_FUNC_DECL GLM_CONSTEXPR_CXX11 vec abs(vec const& x); + GLM_FUNC_DECL GLM_CONSTEXPR_CXX14 vec abs(vec const& x); /// Returns 1.0 if x > 0, 0.0 if x == 0, or -1.0 if x < 0. /// diff --git a/glm/detail/compute_common.hpp b/glm/detail/compute_common.hpp index e8d80f4b..6f743b4e 100644 --- a/glm/detail/compute_common.hpp +++ b/glm/detail/compute_common.hpp @@ -13,7 +13,7 @@ namespace detail template struct compute_abs { - GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX11 static genFIType call(genFIType x) + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 static genFIType call(genFIType x) { GLM_STATIC_ASSERT( std::numeric_limits::is_iec559 || std::numeric_limits::is_signed || GLM_UNRESTRICTED_GENTYPE, @@ -28,7 +28,7 @@ namespace detail template<> struct compute_abs { - GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX11 static float call(float x) + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 static float call(float x) { return fabsf(x); } @@ -38,7 +38,7 @@ namespace detail template struct compute_abs { - GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX11 static genFIType call(genFIType x) + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 static genFIType call(genFIType x) { GLM_STATIC_ASSERT( (!std::numeric_limits::is_signed && std::numeric_limits::is_integer) || GLM_UNRESTRICTED_GENTYPE, diff --git a/glm/detail/compute_vector_relational.hpp b/glm/detail/compute_vector_relational.hpp index ea600b64..61f46437 100644 --- a/glm/detail/compute_vector_relational.hpp +++ b/glm/detail/compute_vector_relational.hpp @@ -10,7 +10,7 @@ namespace detail template struct compute_equal { - GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX11 static bool call(T a, T b) + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 static bool call(T a, T b) { return a == b; } @@ -19,7 +19,7 @@ namespace detail template struct compute_equal { - GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX11 static bool call(T a, T b) + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 static bool call(T a, T b) { return detail::compute_abs::is_signed>::call(b - a) <= static_cast(0); //return std::memcmp(&a, &b, sizeof(T)) == 0; diff --git a/glm/detail/func_common.inl b/glm/detail/func_common.inl index e9c4562d..9d6d04a6 100644 --- a/glm/detail/func_common.inl +++ b/glm/detail/func_common.inl @@ -30,7 +30,7 @@ namespace glm // abs template<> - GLM_FUNC_QUALIFIER int32 abs(int32 x) + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 int32 abs(int32 x) { int32 const y = x >> 31; return (x ^ y) - y; @@ -266,13 +266,13 @@ namespace detail }//namespace detail template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX11 genFIType abs(genFIType x) + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 genFIType abs(genFIType x) { return detail::compute_abs::is_signed>::call(x); } template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX11 vec abs(vec const& x) + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 vec abs(vec const& x) { return detail::compute_abs_vector::value>::call(x); } diff --git a/glm/detail/type_vec1.inl b/glm/detail/type_vec1.inl index 0c97646d..f1a671f8 100644 --- a/glm/detail/type_vec1.inl +++ b/glm/detail/type_vec1.inl @@ -527,25 +527,25 @@ namespace glm // -- Boolean operators -- template - GLM_FUNC_QUALIFIER bool operator==(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2) + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 bool operator==(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2) { return detail::compute_equal::is_iec559>::call(v1.x, v2.x); } template - GLM_FUNC_QUALIFIER bool operator!=(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2) + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 bool operator!=(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2) { return !(v1 == v2); } template - GLM_FUNC_QUALIFIER vec<1, bool, Q> operator&&(vec<1, bool, Q> const& v1, vec<1, bool, Q> const& v2) + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 vec<1, bool, Q> operator&&(vec<1, bool, Q> const& v1, vec<1, bool, Q> const& v2) { return vec<1, bool, Q>(v1.x && v2.x); } template - GLM_FUNC_QUALIFIER vec<1, bool, Q> operator||(vec<1, bool, Q> const& v1, vec<1, bool, Q> const& v2) + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 vec<1, bool, Q> operator||(vec<1, bool, Q> const& v1, vec<1, bool, Q> const& v2) { return vec<1, bool, Q>(v1.x || v2.x); } diff --git a/glm/detail/type_vec2.hpp b/glm/detail/type_vec2.hpp index 178868c5..a8b69b3d 100644 --- a/glm/detail/type_vec2.hpp +++ b/glm/detail/type_vec2.hpp @@ -361,16 +361,16 @@ namespace glm // -- Boolean operators -- template - GLM_FUNC_DECL bool operator==(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2); + GLM_FUNC_DECL GLM_CONSTEXPR_CXX14 bool operator==(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2); template - GLM_FUNC_DECL bool operator!=(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2); + GLM_FUNC_DECL GLM_CONSTEXPR_CXX14 bool operator!=(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2); template - GLM_FUNC_DECL vec<2, bool, Q> operator&&(vec<2, bool, Q> const& v1, vec<2, bool, Q> const& v2); + GLM_FUNC_DECL GLM_CONSTEXPR_CXX14 vec<2, bool, Q> operator&&(vec<2, bool, Q> const& v1, vec<2, bool, Q> const& v2); template - GLM_FUNC_DECL vec<2, bool, Q> operator||(vec<2, bool, Q> const& v1, vec<2, bool, Q> const& v2); + GLM_FUNC_DECL GLM_CONSTEXPR_CXX14 vec<2, bool, Q> operator||(vec<2, bool, Q> const& v1, vec<2, bool, Q> const& v2); }//namespace glm #ifndef GLM_EXTERNAL_TEMPLATE diff --git a/glm/detail/type_vec2.inl b/glm/detail/type_vec2.inl index ec589001..82f8ebe1 100644 --- a/glm/detail/type_vec2.inl +++ b/glm/detail/type_vec2.inl @@ -873,7 +873,7 @@ namespace glm // -- Boolean operators -- template - GLM_FUNC_QUALIFIER bool operator==(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2) + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 bool operator==(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2) { return detail::compute_equal::is_iec559>::call(v1.x, v2.x) && @@ -881,19 +881,19 @@ namespace glm } template - GLM_FUNC_QUALIFIER bool operator!=(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2) + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 bool operator!=(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2) { return !(v1 == v2); } template - GLM_FUNC_QUALIFIER vec<2, bool, Q> operator&&(vec<2, bool, Q> const& v1, vec<2, bool, Q> const& v2) + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 vec<2, bool, Q> operator&&(vec<2, bool, Q> const& v1, vec<2, bool, Q> const& v2) { return vec<2, bool, Q>(v1.x && v2.x, v1.y && v2.y); } template - GLM_FUNC_QUALIFIER vec<2, bool, Q> operator||(vec<2, bool, Q> const& v1, vec<2, bool, Q> const& v2) + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 vec<2, bool, Q> operator||(vec<2, bool, Q> const& v1, vec<2, bool, Q> const& v2) { return vec<2, bool, Q>(v1.x || v2.x, v1.y || v2.y); } diff --git a/glm/detail/type_vec3.hpp b/glm/detail/type_vec3.hpp index 26627138..0e854879 100644 --- a/glm/detail/type_vec3.hpp +++ b/glm/detail/type_vec3.hpp @@ -391,16 +391,16 @@ namespace glm // -- Boolean operators -- template - GLM_FUNC_DECL GLM_CONSTEXPR_CXX11 bool operator==(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2); + GLM_FUNC_DECL GLM_CONSTEXPR_CXX14 bool operator==(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2); template - GLM_FUNC_DECL GLM_CONSTEXPR_CXX11 bool operator!=(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2); + GLM_FUNC_DECL GLM_CONSTEXPR_CXX14 bool operator!=(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2); template - GLM_FUNC_DECL vec<3, bool, Q> operator&&(vec<3, bool, Q> const& v1, vec<3, bool, Q> const& v2); + GLM_FUNC_DECL GLM_CONSTEXPR_CXX14 vec<3, bool, Q> operator&&(vec<3, bool, Q> const& v1, vec<3, bool, Q> const& v2); template - GLM_FUNC_DECL vec<3, bool, Q> operator||(vec<3, bool, Q> const& v1, vec<3, bool, Q> const& v2); + GLM_FUNC_DECL GLM_CONSTEXPR_CXX14 vec<3, bool, Q> operator||(vec<3, bool, Q> const& v1, vec<3, bool, Q> const& v2); }//namespace glm #ifndef GLM_EXTERNAL_TEMPLATE diff --git a/glm/detail/type_vec3.inl b/glm/detail/type_vec3.inl index 580006c4..26fd12af 100644 --- a/glm/detail/type_vec3.inl +++ b/glm/detail/type_vec3.inl @@ -1021,7 +1021,7 @@ namespace glm // -- Boolean operators -- template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX11 bool operator==(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2) + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 bool operator==(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2) { return detail::compute_equal::is_iec559>::call(v1.x, v2.x) && @@ -1030,19 +1030,19 @@ namespace glm } template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX11 bool operator!=(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2) + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 bool operator!=(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2) { return !(v1 == v2); } template - GLM_FUNC_QUALIFIER vec<3, bool, Q> operator&&(vec<3, bool, Q> const& v1, vec<3, bool, Q> const& v2) + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 vec<3, bool, Q> operator&&(vec<3, bool, Q> const& v1, vec<3, bool, Q> const& v2) { return vec<3, bool, Q>(v1.x && v2.x, v1.y && v2.y, v1.z && v2.z); } template - GLM_FUNC_QUALIFIER vec<3, bool, Q> operator||(vec<3, bool, Q> const& v1, vec<3, bool, Q> const& v2) + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 vec<3, bool, Q> operator||(vec<3, bool, Q> const& v1, vec<3, bool, Q> const& v2) { return vec<3, bool, Q>(v1.x || v2.x, v1.y || v2.y, v1.z || v2.z); } diff --git a/glm/detail/type_vec4.hpp b/glm/detail/type_vec4.hpp index 7633bd16..2de274cf 100644 --- a/glm/detail/type_vec4.hpp +++ b/glm/detail/type_vec4.hpp @@ -466,16 +466,16 @@ namespace glm // -- Boolean operators -- template - GLM_FUNC_DECL bool operator==(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2); + GLM_FUNC_DECL GLM_CONSTEXPR_CXX14 bool operator==(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2); template - GLM_FUNC_DECL bool operator!=(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2); + GLM_FUNC_DECL GLM_CONSTEXPR_CXX14 bool operator!=(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2); template - GLM_FUNC_DECL vec<4, bool, Q> operator&&(vec<4, bool, Q> const& v1, vec<4, bool, Q> const& v2); + GLM_FUNC_DECL GLM_CONSTEXPR_CXX14 vec<4, bool, Q> operator&&(vec<4, bool, Q> const& v1, vec<4, bool, Q> const& v2); template - GLM_FUNC_DECL vec<4, bool, Q> operator||(vec<4, bool, Q> const& v1, vec<4, bool, Q> const& v2); + GLM_FUNC_DECL GLM_CONSTEXPR_CXX14 vec<4, bool, Q> operator||(vec<4, bool, Q> const& v1, vec<4, bool, Q> const& v2); }//namespace glm #ifndef GLM_EXTERNAL_TEMPLATE diff --git a/glm/detail/type_vec4.inl b/glm/detail/type_vec4.inl index 840ef306..a465ab6b 100644 --- a/glm/detail/type_vec4.inl +++ b/glm/detail/type_vec4.inl @@ -127,7 +127,7 @@ namespace detail template struct compute_vec4_equal { - GLM_FUNC_QUALIFIER static bool call(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2) + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 static bool call(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2) { return detail::compute_equal::is_iec559>::call(v1.x, v2.x) && @@ -140,7 +140,7 @@ namespace detail template struct compute_vec4_nequal { - GLM_FUNC_QUALIFIER static bool call(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2) + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 static bool call(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2) { return !compute_vec4_equal::value, sizeof(T) * 8, detail::is_aligned::value>::call(v1, v2); } @@ -1118,25 +1118,25 @@ namespace detail // -- Boolean operators -- template - GLM_FUNC_QUALIFIER bool operator==(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2) + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 bool operator==(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2) { return detail::compute_vec4_equal::value, sizeof(T) * 8, detail::is_aligned::value>::call(v1, v2); } template - GLM_FUNC_QUALIFIER bool operator!=(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2) + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 bool operator!=(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2) { return detail::compute_vec4_nequal::value, sizeof(T) * 8, detail::is_aligned::value>::call(v1, v2); } template - GLM_FUNC_QUALIFIER vec<4, bool, Q> operator&&(vec<4, bool, Q> const& v1, vec<4, bool, Q> const& v2) + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 vec<4, bool, Q> operator&&(vec<4, bool, Q> const& v1, vec<4, bool, Q> const& v2) { return vec<4, bool, Q>(v1.x && v2.x, v1.y && v2.y, v1.z && v2.z, v1.w && v2.w); } template - GLM_FUNC_QUALIFIER vec<4, bool, Q> operator||(vec<4, bool, Q> const& v1, vec<4, bool, Q> const& v2) + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 vec<4, bool, Q> operator||(vec<4, bool, Q> const& v1, vec<4, bool, Q> const& v2) { return vec<4, bool, Q>(v1.x || v2.x, v1.y || v2.y, v1.z || v2.z, v1.w || v2.w); } diff --git a/glm/ext/vec1.hpp b/glm/ext/vec1.hpp index d2e792c7..2379e590 100644 --- a/glm/ext/vec1.hpp +++ b/glm/ext/vec1.hpp @@ -285,16 +285,16 @@ namespace glm // -- Boolean operators -- template - GLM_FUNC_DECL bool operator==(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2); + GLM_FUNC_DECL GLM_CONSTEXPR_CXX14 bool operator==(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2); template - GLM_FUNC_DECL bool operator!=(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2); + GLM_FUNC_DECL GLM_CONSTEXPR_CXX14 bool operator!=(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2); template - GLM_FUNC_DECL vec<1, bool, Q> operator&&(vec<1, bool, Q> const& v1, vec<1, bool, Q> const& v2); + GLM_FUNC_DECL GLM_CONSTEXPR_CXX14 vec<1, bool, Q> operator&&(vec<1, bool, Q> const& v1, vec<1, bool, Q> const& v2); template - GLM_FUNC_DECL vec<1, bool, Q> operator||(vec<1, bool, Q> const& v1, vec<1, bool, Q> const& v2); + GLM_FUNC_DECL GLM_CONSTEXPR_CXX14 vec<1, bool, Q> operator||(vec<1, bool, Q> const& v1, vec<1, bool, Q> const& v2); /// 1 component vector of single-precision floating-point numbers using high precision arithmetic in term of ULPs. /// diff --git a/test/core/core_func_common.cpp b/test/core/core_func_common.cpp index 72776238..ef36006a 100644 --- a/test/core/core_func_common.cpp +++ b/test/core/core_func_common.cpp @@ -1291,10 +1291,13 @@ namespace ldexp_ static int test_constexpr() { -#if GLM_HAS_CONSTEXPR_CXX11 +#if GLM_HAS_CONSTEXPR_CXX14 static_assert(glm::abs(1.0f) > 0.0f, "GLM: Failed constexpr"); + static_assert(glm::abs(glm::vec1(1.0f)) != glm::vec1(0.0f), "GLM: Failed constexpr"); + static_assert(glm::abs(glm::vec2(1.0f)) != glm::vec2(0.0f), "GLM: Failed constexpr"); static_assert(glm::abs(glm::vec3(1.0f)) != glm::vec3(0.0f), "GLM: Failed constexpr"); -#endif // GLM_HAS_CONSTEXPR_CXX11 + static_assert(glm::abs(glm::vec4(1.0f)) != glm::vec4(0.0f), "GLM: Failed constexpr"); +#endif // GLM_HAS_CONSTEXPR_CXX14 return 0; } diff --git a/test/core/core_type_vec1.cpp b/test/core/core_type_vec1.cpp index 349a3697..8f65465a 100644 --- a/test/core/core_type_vec1.cpp +++ b/test/core/core_type_vec1.cpp @@ -137,6 +137,16 @@ static int test_vec1_operator_increment() return Error; } +static int test_constexpr() +{ +#if GLM_HAS_CONSTEXPR_CXX14 + static_assert(glm::vec1::length() == 1, "GLM: Failed constexpr"); + static_assert(glm::vec1(1.0f).x > 0.0f, "GLM: Failed constexpr"); +#endif + + return 0; +} + int main() { int Error = 0; @@ -145,6 +155,7 @@ int main() Error += test_vec1_ctor(); Error += test_vec1_operators(); Error += test_vec1_operator_increment(); + Error += test_constexpr(); return Error; } diff --git a/test/core/core_type_vec2.cpp b/test/core/core_type_vec2.cpp index c1a75d82..d2832f5b 100644 --- a/test/core/core_type_vec2.cpp +++ b/test/core/core_type_vec2.cpp @@ -347,7 +347,7 @@ static int test_operator_increment() static int test_constexpr() { -#if GLM_HAS_CONSTEXPR_CXX11 +#if GLM_HAS_CONSTEXPR_CXX14 static_assert(glm::vec2::length() == 2, "GLM: Failed constexpr"); static_assert(glm::vec2(1.0f).x > 0.0f, "GLM: Failed constexpr"); static_assert(glm::vec2(1.0f, -1.0f).x > 0.0f, "GLM: Failed constexpr"); diff --git a/test/core/core_type_vec3.cpp b/test/core/core_type_vec3.cpp index ff3d275e..0fe2efe7 100644 --- a/test/core/core_type_vec3.cpp +++ b/test/core/core_type_vec3.cpp @@ -564,7 +564,7 @@ static int test_operator_increment() static int test_constexpr() { -#if GLM_HAS_CONSTEXPR_CXX11 +#if GLM_HAS_CONSTEXPR_CXX14 static_assert(glm::vec3::length() == 3, "GLM: Failed constexpr"); static_assert(glm::vec3(1.0f).x > 0.0f, "GLM: Failed constexpr"); static_assert(glm::vec3(1.0f) == glm::vec3(1.0f), "GLM: Failed constexpr"); diff --git a/test/core/core_type_vec4.cpp b/test/core/core_type_vec4.cpp index b6883439..b12ecfe3 100644 --- a/test/core/core_type_vec4.cpp +++ b/test/core/core_type_vec4.cpp @@ -711,10 +711,10 @@ static int test_inheritance() static int test_constexpr() { -#if GLM_HAS_CONSTEXPR_CXX11 +#if GLM_HAS_CONSTEXPR_CXX14 static_assert(glm::vec4::length() == 4, "GLM: Failed constexpr"); static_assert(glm::vec4(1.0f).x > 0.0f, "GLM: Failed constexpr"); - //static_assert(glm::vec4(1.0f) == glm::vec4(1.0f), "GLM: Failed constexpr"); + static_assert(glm::vec4(1.0f) == glm::vec4(1.0f), "GLM: Failed constexpr"); static_assert(glm::vec4(1.0f, -1.0f, -1.0f, -1.0f).x > 0.0f, "GLM: Failed constexpr"); static_assert(glm::vec4(1.0f, -1.0f, -1.0f, -1.0f).y < 0.0f, "GLM: Failed constexpr"); #endif