From 13ca6771ca0edd97501729acd29d3236e78c088a Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Tue, 7 Aug 2018 20:44:44 +0200 Subject: [PATCH] Fixed constexpr build... --- glm/detail/func_vector_relational.inl | 86 +++++++++++++-------------- test/core/core_cpp_constexpr.cpp | 1 - test/core/core_func_common.cpp | 8 +-- test/core/core_type_mat3x3.cpp | 4 +- test/core/core_type_vec3.cpp | 1 - test/core/core_type_vec4.cpp | 1 - test/ext/ext_scalar_relational.cpp | 16 +++-- 7 files changed, 58 insertions(+), 59 deletions(-) diff --git a/glm/detail/func_vector_relational.inl b/glm/detail/func_vector_relational.inl index c38e48b3..5d7fc597 100644 --- a/glm/detail/func_vector_relational.inl +++ b/glm/detail/func_vector_relational.inl @@ -122,25 +122,6 @@ namespace detail } }; - template - struct reduce_relational - { - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR static void call(bool& Dst, vecType const& Src) - { - Dst = relational::call(Dst, Src[I]); - reduce_relational::call(Dst, Src); - } - }; - - template - struct reduce_relational - { - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR static void call(bool&, vecType const&) - {} - }; - template struct loop_relational { @@ -159,8 +140,51 @@ namespace detail GLM_FUNC_QUALIFIER GLM_CONSTEXPR static void call(vecBType&, vecType const&, vecType const&) {} }; + + template + struct reduce_relational + { + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR static void call(bool& Dst, vecType const& Src) + { + Dst = relational::call(Dst, Src[I]); + reduce_relational::call(Dst, Src); + } + }; + + template + struct reduce_relational + { + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR static void call(bool&, vecType const&) + {} + }; }//namespace detail + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool any(vec const& v) + { + bool Result = false; + detail::reduce_relational<0, L, detail::ANY>::call(Result, v); + return Result; + } + + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool all(vec const& v) + { + bool Result = true; + detail::reduce_relational<0, L, detail::ALL>::call(Result, v); + return Result; + } + + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec not_(vec const& v) + { + vec Result; + detail::loop_relational<0, L, detail::NOT>::call(Result, v, v); + return Result; + } + template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec lessThan(vec const& x, vec const& y) { @@ -208,30 +232,6 @@ namespace detail detail::loop_relational<0, L, detail::NOT_EQUAL>::call(Result, x, y); return Result; } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool any(vec const& v) - { - bool Result = false; - detail::reduce_relational<0, L, detail::ANY>::call(Result, v); - return Result; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool all(vec const& v) - { - bool Result = true; - detail::reduce_relational<0, L, detail::ALL>::call(Result, v); - return Result; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec not_(vec const& v) - { - vec Result; - detail::loop_relational<0, L, detail::NOT>::call(Result, v, v); - return Result; - } }//namespace glm #if GLM_CONFIG_SIMD == GLM_ENABLE diff --git a/test/core/core_cpp_constexpr.cpp b/test/core/core_cpp_constexpr.cpp index 2195a6f8..3c2fa3d5 100644 --- a/test/core/core_cpp_constexpr.cpp +++ b/test/core/core_cpp_constexpr.cpp @@ -650,7 +650,6 @@ static int test_quat() glm::quat constexpr Q = glm::identity(); static_assert(Q.x - glm::quat(1.0f, glm::vec3(0.0f)).x <= glm::epsilon(), "GLM: Failed constexpr"); - static_assert(Q[0] == 0, "GLM: Failed constexpr"); } return Error; diff --git a/test/core/core_func_common.cpp b/test/core/core_func_common.cpp index 4eb2017b..33a79be9 100644 --- a/test/core/core_func_common.cpp +++ b/test/core/core_func_common.cpp @@ -1298,10 +1298,10 @@ static int test_constexpr() { #if GLM_HAS_CONSTEXPR 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"); - static_assert(glm::abs(glm::vec4(1.0f)) != glm::vec4(0.0f), "GLM: Failed constexpr"); + constexpr glm::vec1 const A = glm::abs(glm::vec1(1.0f)); + constexpr glm::vec2 const B = glm::abs(glm::vec2(1.0f)); + constexpr glm::vec3 const C = glm::abs(glm::vec3(1.0f)); + constexpr glm::vec4 const D = glm::abs(glm::vec4(1.0f)); #endif // GLM_HAS_CONSTEXPR return 0; diff --git a/test/core/core_type_mat3x3.cpp b/test/core/core_type_mat3x3.cpp index 7d123a94..9c2a0e68 100644 --- a/test/core/core_type_mat3x3.cpp +++ b/test/core/core_type_mat3x3.cpp @@ -187,9 +187,7 @@ static int test_constexpr() #if GLM_HAS_CONSTEXPR static_assert(glm::mat3x3::length() == 3, "GLM: Failed constexpr"); - GLM_CONSTEXPR glm::mat3x3 const Z(0.0f); - static_assert(Z[0] == glm::vec3(0.0f), "GLM: Failed constexpr"); - static_assert(Z == glm::mat3x3(0.0f), "GLM: Failed constexpr"); + constexpr glm::mat3x3 const Z(0.0f); #endif return 0; diff --git a/test/core/core_type_vec3.cpp b/test/core/core_type_vec3.cpp index a8774d0d..78fc5728 100644 --- a/test/core/core_type_vec3.cpp +++ b/test/core/core_type_vec3.cpp @@ -600,7 +600,6 @@ static int test_constexpr() #if GLM_HAS_CONSTEXPR 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"); static_assert(glm::vec3(1.0f, -1.0f, -1.0f).x > 0.0f, "GLM: Failed constexpr"); static_assert(glm::vec3(1.0f, -1.0f, -1.0f).y < 0.0f, "GLM: Failed constexpr"); #endif diff --git a/test/core/core_type_vec4.cpp b/test/core/core_type_vec4.cpp index 27e5f17e..f69087fa 100644 --- a/test/core/core_type_vec4.cpp +++ b/test/core/core_type_vec4.cpp @@ -754,7 +754,6 @@ static int test_constexpr() #if GLM_HAS_CONSTEXPR 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, -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 diff --git a/test/ext/ext_scalar_relational.cpp b/test/ext/ext_scalar_relational.cpp index a4c2bfdc..688f847c 100644 --- a/test/ext/ext_scalar_relational.cpp +++ b/test/ext/ext_scalar_relational.cpp @@ -2,9 +2,11 @@ int test_equal() { - static_assert(glm::equal(1.01f, 1.02f, 0.1f), "GLM: Failed constexpr"); - static_assert(!glm::equal(1.01f, 1.02f, 0.001f), "GLM: Failed constexpr"); - +# if GLM_CONFIG_CONSTEXP == GLM_ENABLE + static_assert(glm::equal(1.01f, 1.02f, 0.1f), "GLM: Failed constexpr"); + static_assert(!glm::equal(1.01f, 1.02f, 0.001f), "GLM: Failed constexpr"); +# endif + int Error = 0; Error += glm::equal(1.01f, 1.02f, 0.1f) ? 0 : 1; @@ -15,9 +17,11 @@ int test_equal() int test_notEqual() { - static_assert(glm::notEqual(1.01f, 1.02f, 0.001f), "GLM: Failed constexpr"); - static_assert(!glm::notEqual(1.01f, 1.02f, 0.1f), "GLM: Failed constexpr"); - +# if GLM_CONFIG_CONSTEXP == GLM_ENABLE + static_assert(glm::notEqual(1.01f, 1.02f, 0.001f), "GLM: Failed constexpr"); + static_assert(!glm::notEqual(1.01f, 1.02f, 0.1f), "GLM: Failed constexpr"); +# endif + int Error = 0; Error += glm::notEqual(1.01f, 1.02f, 0.001f) ? 0 : 1;