From 4eb3fe1d7d8fd407cc7ccfa801a0311bb7dd281c Mon Sep 17 00:00:00 2001 From: Christophe Date: Tue, 6 Feb 2024 16:24:25 +0100 Subject: [PATCH] fcomp: Fix build in C++98 mode --- glm/gtx/component_wise.inl | 9 +++++---- test/gtx/gtx_component_wise.cpp | 15 +++++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/glm/gtx/component_wise.inl b/glm/gtx/component_wise.inl index 3a993dbc..f8217b2e 100644 --- a/glm/gtx/component_wise.inl +++ b/glm/gtx/component_wise.inl @@ -1,5 +1,6 @@ /// @ref gtx_component_wise +#include "../ext/scalar_common.hpp" #include #include @@ -126,21 +127,21 @@ namespace detail return Result; } - template::value, T>::type> + template GLM_FUNC_QUALIFIER T fcompMin(vec const& v) { T Result(v[0]); for(length_t i = 1, n = v.length(); i < n; ++i) - Result = std::fmin(Result, v[i]); + Result = fmin(Result, v[i]); return Result; } - template::value, T>::type> + template GLM_FUNC_QUALIFIER T fcompMax(vec const& v) { T Result(v[0]); for(length_t i = 1, n = v.length(); i < n; ++i) - Result = std::fmax(Result, v[i]); + Result = fmax(Result, v[i]); return Result; } }//namespace glm diff --git a/test/gtx/gtx_component_wise.cpp b/test/gtx/gtx_component_wise.cpp index f8d8c781..03a91b1b 100644 --- a/test/gtx/gtx_component_wise.cpp +++ b/test/gtx/gtx_component_wise.cpp @@ -3,6 +3,8 @@ #include #include #include +#include +#include #include namespace compNormalize @@ -105,6 +107,7 @@ namespace compScale } }// compScale +#if ((GLM_LANG & GLM_LANG_CXX11_FLAG) || (GLM_COMPILER & GLM_COMPILER_VC)) namespace fcompMax { static int run() @@ -114,13 +117,13 @@ namespace fcompMax { float const A = glm::fcompMax(glm::vec4(NAN, 0.2f, 0.5f, 1.0f)); - Error += A == 1.0f ? 0 : 1; + Error += glm::equal(A, 1.0f, glm::epsilon()) ? 0 : 1; } { float const A = glm::fcompMax(glm::vec4(2.0f, NAN, 0.3f, 0.7f)); - Error += A == 2.0f ? 0 : 1; + Error += glm::equal(A, 2.0f, glm::epsilon()) ? 0 : 1; } { @@ -142,13 +145,13 @@ namespace fcompMin { float const A = glm::fcompMin(glm::vec4(NAN, 0.2f, 0.5f, 1.0f)); - Error += A == 0.2f ? 0 : 1; + Error += glm::equal(A, 0.2f, glm::epsilon()) ? 0 : 1; } { float const A = glm::fcompMin(glm::vec4(2.0f, NAN, 0.3f, 0.7f)); - Error += A == 0.3f ? 0 : 1; + Error += glm::equal(A, 0.3f, glm::epsilon()) ? 0 : 1; } { @@ -161,6 +164,7 @@ namespace fcompMin return Error; } }// fcompMin +#endif//((GLM_LANG & GLM_LANG_CXX11_FLAG) || (GLM_COMPILER & GLM_COMPILER_VC)) int main() { @@ -168,8 +172,11 @@ int main() Error += compNormalize::run(); Error += compScale::run(); + +#if ((GLM_LANG & GLM_LANG_CXX11_FLAG) || (GLM_COMPILER & GLM_COMPILER_VC)) Error += fcompMax::run(); Error += fcompMin::run(); +#endif//((GLM_LANG & GLM_LANG_CXX11_FLAG) || (GLM_COMPILER & GLM_COMPILER_VC)) return Error; }