From d9470190b73c36012f417f5bac3f857f22183b9b Mon Sep 17 00:00:00 2001 From: Joris Vaillant Date: Wed, 5 Jun 2024 15:17:58 +0200 Subject: [PATCH] Use CppAD macro to define `CppAD::numeric_limits` specialization CppAD 2024 add a `max_digits10` member to `CppAD::numeric_limits`. This member is not defined in CppADCodeGen and this create compilation issue with clang based compiler. To avoid future issue, we use `CPPAD_NUMERIC_LIMITS` macro that will ensure we always have an up to date version of `CppAD::numeric_limits`. See [CppAD#206](https://github.com/coin-or/CppAD/issues/206). --- include/cppad/cg/base_double.hpp | 24 +----------------------- include/cppad/cg/base_float.hpp | 24 +----------------------- 2 files changed, 2 insertions(+), 46 deletions(-) diff --git a/include/cppad/cg/base_double.hpp b/include/cppad/cg/base_double.hpp index 38829192..66549d5c 100644 --- a/include/cppad/cg/base_double.hpp +++ b/include/cppad/cg/base_double.hpp @@ -20,29 +20,7 @@ namespace CppAD { /** * Specialization of the numeric_limits for doubles */ -template <> -class numeric_limits > { -public: - - static cg::CG epsilon() { - return std::numeric_limits::epsilon(); - } - - static cg::CG min() { - return (std::numeric_limits::min)(); - } - - static cg::CG max() { - return (std::numeric_limits::max)(); - } - - static cg::CG quiet_NaN() { - return std::numeric_limits::quiet_NaN(); - } - - static const int digits10 - = std::numeric_limits::digits10; -}; +CPPAD_NUMERIC_LIMITS(double, cg::CG) /** * Specialization of the machine epsilon for CG diff --git a/include/cppad/cg/base_float.hpp b/include/cppad/cg/base_float.hpp index 57ac8522..4dd50d8f 100644 --- a/include/cppad/cg/base_float.hpp +++ b/include/cppad/cg/base_float.hpp @@ -20,29 +20,7 @@ namespace CppAD { /** * Specialization of the numeric_limits for floats */ -template <> -class numeric_limits > { -public: - - static cg::CG epsilon() { - return std::numeric_limits::epsilon(); - } - - static cg::CG min() { - return std::numeric_limits::min(); - } - - static cg::CG max() { - return std::numeric_limits::max(); - } - - static cg::CG quiet_NaN() { - return std::numeric_limits::quiet_NaN(); - } - - static const int digits10 - = std::numeric_limits::digits10; -}; +CPPAD_NUMERIC_LIMITS(float, cg::CG) /** * Specialization of the machine epsilon for CG