diff --git a/upstream_utils/gcem_patches/0001-Call-std-functions-if-not-constant-evaluated.patch b/upstream_utils/gcem_patches/0001-Call-std-functions-if-not-constant-evaluated.patch new file mode 100644 index 0000000000..afea15ef9a --- /dev/null +++ b/upstream_utils/gcem_patches/0001-Call-std-functions-if-not-constant-evaluated.patch @@ -0,0 +1,993 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Tyler Veness +Date: Sun, 26 Nov 2023 18:09:12 -0800 +Subject: [PATCH] Call std functions if not constant-evaluated + +--- + include/gcem_incl/abs.hpp | 7 +++++++ + include/gcem_incl/acos.hpp | 7 +++++++ + include/gcem_incl/acosh.hpp | 7 +++++++ + include/gcem_incl/asin.hpp | 7 +++++++ + include/gcem_incl/asinh.hpp | 7 +++++++ + include/gcem_incl/atan.hpp | 7 +++++++ + include/gcem_incl/atan2.hpp | 7 +++++++ + include/gcem_incl/atanh.hpp | 7 +++++++ + include/gcem_incl/beta.hpp | 11 +++++++++++ + include/gcem_incl/ceil.hpp | 7 +++++++ + include/gcem_incl/copysign.hpp | 7 +++++++ + include/gcem_incl/cos.hpp | 7 +++++++ + include/gcem_incl/cosh.hpp | 7 +++++++ + include/gcem_incl/erf.hpp | 7 +++++++ + include/gcem_incl/exp.hpp | 7 +++++++ + include/gcem_incl/expm1.hpp | 7 +++++++ + include/gcem_incl/floor.hpp | 7 +++++++ + include/gcem_incl/fmod.hpp | 7 +++++++ + include/gcem_incl/hypot.hpp | 7 +++++++ + include/gcem_incl/lgamma.hpp | 7 +++++++ + include/gcem_incl/log.hpp | 7 +++++++ + include/gcem_incl/log10.hpp | 7 +++++++ + include/gcem_incl/log1p.hpp | 7 +++++++ + include/gcem_incl/log2.hpp | 7 +++++++ + include/gcem_incl/max.hpp | 7 +++++++ + include/gcem_incl/min.hpp | 7 +++++++ + include/gcem_incl/pow.hpp | 7 +++++++ + include/gcem_incl/round.hpp | 7 +++++++ + include/gcem_incl/signbit.hpp | 7 +++++++ + include/gcem_incl/sin.hpp | 7 +++++++ + include/gcem_incl/sinh.hpp | 7 +++++++ + include/gcem_incl/sqrt.hpp | 7 +++++++ + include/gcem_incl/tan.hpp | 7 +++++++ + include/gcem_incl/tanh.hpp | 7 +++++++ + include/gcem_incl/tgamma.hpp | 7 +++++++ + include/gcem_incl/trunc.hpp | 7 +++++++ + 36 files changed, 256 insertions(+) + +diff --git a/include/gcem_incl/abs.hpp b/include/gcem_incl/abs.hpp +index 6d7b66d91bc9f4d0c05fd0c3dd1571b552d8a19a..32ee89494c088a51862f00aecadeb180c0159997 100644 +--- a/include/gcem_incl/abs.hpp ++++ b/include/gcem_incl/abs.hpp +@@ -21,6 +21,9 @@ + #ifndef _gcem_abs_HPP + #define _gcem_abs_HPP + ++#include ++#include ++ + /** + * Compile-time absolute value function + * +@@ -34,12 +37,16 @@ T + abs(const T x) + noexcept + { ++ if (std::is_constant_evaluated()) { + return( // deal with signed-zeros + x == T(0) ? \ + T(0) : + // else + x < T(0) ? \ + - x : x ); ++ } else { ++ return std::abs(x); ++ } + } + + #endif +diff --git a/include/gcem_incl/acos.hpp b/include/gcem_incl/acos.hpp +index a47003d61d8ab2fb7dd0226410e1457809a73458..c40006de7f3747c8eb2678dc5c1187d6f72a30e3 100644 +--- a/include/gcem_incl/acos.hpp ++++ b/include/gcem_incl/acos.hpp +@@ -25,6 +25,9 @@ + #ifndef _gcem_acos_HPP + #define _gcem_acos_HPP + ++#include ++#include ++ + namespace internal + { + +@@ -78,7 +81,11 @@ return_t + acos(const T x) + noexcept + { ++ if (std::is_constant_evaluated()) { + return internal::acos_check( static_cast>(x) ); ++ } else { ++ return std::acos(x); ++ } + } + + #endif +diff --git a/include/gcem_incl/acosh.hpp b/include/gcem_incl/acosh.hpp +index 8767200778168aeb409f16945b2ceac75b69158d..edf71db655bacd376174fdf212312ec201dc48a6 100644 +--- a/include/gcem_incl/acosh.hpp ++++ b/include/gcem_incl/acosh.hpp +@@ -25,6 +25,9 @@ + #ifndef _gcem_acosh_HPP + #define _gcem_acosh_HPP + ++#include ++#include ++ + namespace internal + { + +@@ -62,7 +65,11 @@ return_t + acosh(const T x) + noexcept + { ++ if (std::is_constant_evaluated()) { + return internal::acosh_compute( static_cast>(x) ); ++ } else { ++ return std::acosh(x); ++ } + } + + #endif +diff --git a/include/gcem_incl/asin.hpp b/include/gcem_incl/asin.hpp +index 6a79e87df435c7e60b140b7c7133b22deea7fd73..57840d4b1a0dba4943662b2cf2979ec14ace16f0 100644 +--- a/include/gcem_incl/asin.hpp ++++ b/include/gcem_incl/asin.hpp +@@ -25,6 +25,9 @@ + #ifndef _gcem_asin_HPP + #define _gcem_asin_HPP + ++#include ++#include ++ + namespace internal + { + +@@ -76,7 +79,11 @@ return_t + asin(const T x) + noexcept + { ++ if (std::is_constant_evaluated()) { + return internal::asin_check( static_cast>(x) ); ++ } else { ++ return std::asin(x); ++ } + } + + #endif +diff --git a/include/gcem_incl/asinh.hpp b/include/gcem_incl/asinh.hpp +index a5f3ff62a0208d350f4027d736ce3fc035c16ded..7e5190289abe60eb591a4f43db41370b10892949 100644 +--- a/include/gcem_incl/asinh.hpp ++++ b/include/gcem_incl/asinh.hpp +@@ -25,6 +25,9 @@ + #ifndef _gcem_asinh_HPP + #define _gcem_asinh_HPP + ++#include ++#include ++ + namespace internal + { + +@@ -59,7 +62,11 @@ return_t + asinh(const T x) + noexcept + { ++ if (std::is_constant_evaluated()) { + return internal::asinh_compute( static_cast>(x) ); ++ } else { ++ return std::asinh(x); ++ } + } + + +diff --git a/include/gcem_incl/atan.hpp b/include/gcem_incl/atan.hpp +index 3f46974c07920fca6396e42e93261d8167a27eb1..9ebd33e65d06d14d5091e60f660e1769835f4ade 100644 +--- a/include/gcem_incl/atan.hpp ++++ b/include/gcem_incl/atan.hpp +@@ -29,6 +29,9 @@ + #ifndef _gcem_atan_HPP + #define _gcem_atan_HPP + ++#include ++#include ++ + namespace internal + { + +@@ -149,7 +152,11 @@ return_t + atan(const T x) + noexcept + { ++ if (std::is_constant_evaluated()) { + return internal::atan_check( static_cast>(x) ); ++ } else { ++ return std::atan(x); ++ } + } + + #endif +diff --git a/include/gcem_incl/atan2.hpp b/include/gcem_incl/atan2.hpp +index 5ca55b79c8e11569511fb6d4842c74be50c70c67..d3abcd88c9e0c1e0f3f62659934cb101b8478214 100644 +--- a/include/gcem_incl/atan2.hpp ++++ b/include/gcem_incl/atan2.hpp +@@ -25,6 +25,9 @@ + #ifndef _gcem_atan2_HPP + #define _gcem_atan2_HPP + ++#include ++#include ++ + namespace internal + { + +@@ -82,7 +85,11 @@ common_return_t + atan2(const T1 y, const T2 x) + noexcept + { ++ if (std::is_constant_evaluated()) { + return internal::atan2_type_check(x,y); ++ } else { ++ return std::atan2(y, x); ++ } + } + + #endif +diff --git a/include/gcem_incl/atanh.hpp b/include/gcem_incl/atanh.hpp +index dfb4dc312d479e2c6dd837d2391bc658e3b678ed..753d469857e5d618c447887f03991a76ab9043a5 100644 +--- a/include/gcem_incl/atanh.hpp ++++ b/include/gcem_incl/atanh.hpp +@@ -25,6 +25,9 @@ + #ifndef _gcem_atanh_HPP + #define _gcem_atanh_HPP + ++#include ++#include ++ + namespace internal + { + +@@ -73,7 +76,11 @@ return_t + atanh(const T x) + noexcept + { ++ if (std::is_constant_evaluated()) { + return internal::atanh_check( static_cast>(x) ); ++ } else { ++ return std::atanh(x); ++ } + } + + #endif +diff --git a/include/gcem_incl/beta.hpp b/include/gcem_incl/beta.hpp +index e43d4fcd9a10e37e16652351ec7092cb7200f808..b7da514a255b71714766deeee87906e4af3bef09 100644 +--- a/include/gcem_incl/beta.hpp ++++ b/include/gcem_incl/beta.hpp +@@ -21,6 +21,9 @@ + #ifndef _gcem_beta_HPP + #define _gcem_beta_HPP + ++#include ++#include ++ + /** + * Compile-time beta function + * +@@ -36,7 +39,15 @@ common_return_t + beta(const T1 a, const T2 b) + noexcept + { ++ if (std::is_constant_evaluated()) { ++ return exp( lbeta(a,b) ); ++ } else { ++#ifdef __cpp_lib_math_special_functions ++ return std::beta(a, b); ++#else + return exp( lbeta(a,b) ); ++#endif ++ } + } + + #endif +diff --git a/include/gcem_incl/ceil.hpp b/include/gcem_incl/ceil.hpp +index ff1097bac2f53c3f6a4b3d4bfc612e0fcd34a63b..257ff0550c50f3ac5e82b1d08905e1a13a5c88ed 100644 +--- a/include/gcem_incl/ceil.hpp ++++ b/include/gcem_incl/ceil.hpp +@@ -21,6 +21,9 @@ + #ifndef _gcem_ceil_HPP + #define _gcem_ceil_HPP + ++#include ++#include ++ + namespace internal + { + +@@ -124,7 +127,11 @@ return_t + ceil(const T x) + noexcept + { ++ if (std::is_constant_evaluated()) { + return internal::ceil_check( static_cast>(x) ); ++ } else { ++ return std::ceil(x); ++ } + } + + #endif +diff --git a/include/gcem_incl/copysign.hpp b/include/gcem_incl/copysign.hpp +index c1741f7f321110ff3cf52cb9035d5f2dca5f0ffc..eecfea21a2dd431243a55c3bcdebc5f7ddbb2297 100644 +--- a/include/gcem_incl/copysign.hpp ++++ b/include/gcem_incl/copysign.hpp +@@ -21,6 +21,9 @@ + #ifndef _gcem_copysign_HPP + #define _gcem_copysign_HPP + ++#include ++#include ++ + /** + * Compile-time copy sign function + * +@@ -35,7 +38,11 @@ T1 + copysign(const T1 x, const T2 y) + noexcept + { ++ if (std::is_constant_evaluated()) { + return( signbit(x) != signbit(y) ? -x : x ); ++ } else { ++ return std::copysign(x, y); ++ } + } + + #endif +diff --git a/include/gcem_incl/cos.hpp b/include/gcem_incl/cos.hpp +index 82f4c609f5268d19771e281987ed1653e81ef173..9c8181bb991508d79c5fc427c6e5c4c1ae0b46fa 100644 +--- a/include/gcem_incl/cos.hpp ++++ b/include/gcem_incl/cos.hpp +@@ -25,6 +25,9 @@ + #ifndef _gcem_cos_HPP + #define _gcem_cos_HPP + ++#include ++#include ++ + namespace internal + { + +@@ -77,7 +80,11 @@ return_t + cos(const T x) + noexcept + { ++ if (std::is_constant_evaluated()) { + return internal::cos_check( static_cast>(x) ); ++ } else { ++ return std::cos(x); ++ } + } + + #endif +diff --git a/include/gcem_incl/cosh.hpp b/include/gcem_incl/cosh.hpp +index fc89c0d06482a687442998da511eb1e7b17f95d5..225c37a011857725ff77af8e0ff3cd3d779843e4 100644 +--- a/include/gcem_incl/cosh.hpp ++++ b/include/gcem_incl/cosh.hpp +@@ -25,6 +25,9 @@ + #ifndef _gcem_cosh_HPP + #define _gcem_cosh_HPP + ++#include ++#include ++ + namespace internal + { + +@@ -59,7 +62,11 @@ return_t + cosh(const T x) + noexcept + { ++ if (std::is_constant_evaluated()) { + return internal::cosh_compute( static_cast>(x) ); ++ } else { ++ return std::cosh(x); ++ } + } + + #endif +diff --git a/include/gcem_incl/erf.hpp b/include/gcem_incl/erf.hpp +index d0bc83ada14af7a4b50262541c8558016823303a..ee5386325b1cde9a447c384488afb837358c5fef 100644 +--- a/include/gcem_incl/erf.hpp ++++ b/include/gcem_incl/erf.hpp +@@ -25,6 +25,9 @@ + #ifndef _gcem_erf_HPP + #define _gcem_erf_HPP + ++#include ++#include ++ + namespace internal + { + +@@ -137,7 +140,11 @@ return_t + erf(const T x) + noexcept + { ++ if (std::is_constant_evaluated()) { + return internal::erf_check( static_cast>(x) ); ++ } else { ++ return std::erf(x); ++ } + } + + #endif +diff --git a/include/gcem_incl/exp.hpp b/include/gcem_incl/exp.hpp +index 595ffc2a6202d763560fd879f27fcef32c6b2d64..acbda39377fbf9936a439e71dd760fb6203bd138 100644 +--- a/include/gcem_incl/exp.hpp ++++ b/include/gcem_incl/exp.hpp +@@ -25,6 +25,9 @@ + #ifndef _gcem_exp_HPP + #define _gcem_exp_HPP + ++#include ++#include ++ + namespace internal + { + +@@ -124,7 +127,11 @@ return_t + exp(const T x) + noexcept + { ++ if (std::is_constant_evaluated()) { + return internal::exp_check( static_cast>(x) ); ++ } else { ++ return std::exp(x); ++ } + } + + #endif +diff --git a/include/gcem_incl/expm1.hpp b/include/gcem_incl/expm1.hpp +index 70c9ecf5a4a241bfef617e6e4ee0000a80978355..edecd394cfc54e32713d7ed381db6fa8e0057983 100644 +--- a/include/gcem_incl/expm1.hpp ++++ b/include/gcem_incl/expm1.hpp +@@ -25,6 +25,9 @@ + #ifndef _gcem_expm1_HPP + #define _gcem_expm1_HPP + ++#include ++#include ++ + namespace internal + { + +@@ -70,7 +73,11 @@ return_t + expm1(const T x) + noexcept + { ++ if (std::is_constant_evaluated()) { + return internal::expm1_check( static_cast>(x) ); ++ } else { ++ return std::expm1(x); ++ } + } + + #endif +diff --git a/include/gcem_incl/floor.hpp b/include/gcem_incl/floor.hpp +index 8b260ff8a10fb8b9d048307c7d9b18a7e91900c1..e35592a391e03934a45a943ffb92ae3c264d768c 100644 +--- a/include/gcem_incl/floor.hpp ++++ b/include/gcem_incl/floor.hpp +@@ -21,6 +21,9 @@ + #ifndef _gcem_floor_HPP + #define _gcem_floor_HPP + ++#include ++#include ++ + namespace internal + { + +@@ -124,7 +127,11 @@ return_t + floor(const T x) + noexcept + { ++ if (std::is_constant_evaluated()) { + return internal::floor_check( static_cast>(x) ); ++ } else { ++ return std::floor(x); ++ } + } + + #endif +diff --git a/include/gcem_incl/fmod.hpp b/include/gcem_incl/fmod.hpp +index 02459efd4b3a016939a306c9fd1a7ead12ff123b..2f503140e354e05d03dadd2077b60879f80acd61 100644 +--- a/include/gcem_incl/fmod.hpp ++++ b/include/gcem_incl/fmod.hpp +@@ -21,6 +21,9 @@ + #ifndef _gcem_fmod_HPP + #define _gcem_fmod_HPP + ++#include ++#include ++ + namespace internal + { + +@@ -64,7 +67,11 @@ common_return_t + fmod(const T1 x, const T2 y) + noexcept + { ++ if (std::is_constant_evaluated()) { + return internal::fmod_type_check(x,y); ++ } else { ++ return std::fmod(x, y); ++ } + } + + #endif +diff --git a/include/gcem_incl/hypot.hpp b/include/gcem_incl/hypot.hpp +index 01ad4e9212547c649113e50954a73ee9f7394334..c51a5b42e57520b94d50b497ec4aa4bb33b0b774 100644 +--- a/include/gcem_incl/hypot.hpp ++++ b/include/gcem_incl/hypot.hpp +@@ -27,6 +27,9 @@ + #ifndef _gcem_hypot_HPP + #define _gcem_hypot_HPP + ++#include ++#include ++ + namespace internal + { + +@@ -84,7 +87,11 @@ common_return_t + hypot(const T1 x, const T2 y) + noexcept + { ++ if (std::is_constant_evaluated()) { + return internal::hypot_type_check(x,y); ++ } else { ++ return std::hypot(x, y); ++ } + } + + #endif +diff --git a/include/gcem_incl/lgamma.hpp b/include/gcem_incl/lgamma.hpp +index 507c6d4c91423b31be55426f494f67b0cb085c9f..7c11fe56ad1156eb51ab9d9acbe0a4406a9e6c4e 100644 +--- a/include/gcem_incl/lgamma.hpp ++++ b/include/gcem_incl/lgamma.hpp +@@ -28,6 +28,9 @@ + #ifndef _gcem_lgamma_HPP + #define _gcem_lgamma_HPP + ++#include ++#include ++ + namespace internal + { + +@@ -129,7 +132,11 @@ return_t + lgamma(const T x) + noexcept + { ++ if (std::is_constant_evaluated()) { + return internal::lgamma_check( static_cast>(x) ); ++ } else { ++ return std::lgamma(x); ++ } + } + + #endif +diff --git a/include/gcem_incl/log.hpp b/include/gcem_incl/log.hpp +index c2e24b006c2fdd01196b189220f35ca982d8bf9e..b9f1f02cedbacf88538626dda43729bc75495b1f 100644 +--- a/include/gcem_incl/log.hpp ++++ b/include/gcem_incl/log.hpp +@@ -25,6 +25,9 @@ + #ifndef _gcem_log_HPP + #define _gcem_log_HPP + ++#include ++#include ++ + namespace internal + { + +@@ -180,7 +183,11 @@ return_t + log(const T x) + noexcept + { ++ if (std::is_constant_evaluated()) { + return internal::log_integral_check( x ); ++ } else { ++ return std::log(x); ++ } + } + + #endif +diff --git a/include/gcem_incl/log10.hpp b/include/gcem_incl/log10.hpp +index cda8894fdd62054f11ec4c3c3e6402c3752e0dd7..0d4ff3ecb0f7a1314c35197e51e75a78c3128b74 100644 +--- a/include/gcem_incl/log10.hpp ++++ b/include/gcem_incl/log10.hpp +@@ -25,6 +25,9 @@ + #ifndef _gcem_log10_HPP + #define _gcem_log10_HPP + ++#include ++#include ++ + namespace internal + { + +@@ -53,7 +56,11 @@ return_t + log10(const T x) + noexcept + { ++ if (std::is_constant_evaluated()) { + return internal::log10_check( x ); ++ } else { ++ return std::log10(x); ++ } + } + + #endif +diff --git a/include/gcem_incl/log1p.hpp b/include/gcem_incl/log1p.hpp +index ccd08b8cb8799f2d4d34d5634dbc2fcabb3fd5b3..b7e6cd534dedb8f55c7a3e9dd03af15d6a19837f 100644 +--- a/include/gcem_incl/log1p.hpp ++++ b/include/gcem_incl/log1p.hpp +@@ -25,6 +25,9 @@ + #ifndef _gcem_log1p_HPP + #define _gcem_log1p_HPP + ++#include ++#include ++ + namespace internal + { + +@@ -74,7 +77,11 @@ return_t + log1p(const T x) + noexcept + { ++ if (std::is_constant_evaluated()) { + return internal::log1p_check( static_cast>(x) ); ++ } else { ++ return std::log1p(x); ++ } + } + + #endif +diff --git a/include/gcem_incl/log2.hpp b/include/gcem_incl/log2.hpp +index a97fed4c7236f816fa07ac2494f243adbac6742b..37196152d060f7380ff57e084b2b2e119c69587d 100644 +--- a/include/gcem_incl/log2.hpp ++++ b/include/gcem_incl/log2.hpp +@@ -25,6 +25,9 @@ + #ifndef _gcem_log2_HPP + #define _gcem_log2_HPP + ++#include ++#include ++ + namespace internal + { + +@@ -53,7 +56,11 @@ return_t + log2(const T x) + noexcept + { ++ if (std::is_constant_evaluated()) { + return internal::log2_check( x ); ++ } else { ++ return std::log2(x); ++ } + } + + #endif +diff --git a/include/gcem_incl/max.hpp b/include/gcem_incl/max.hpp +index ddc3e4e6caff1a781e662a3ded8909cb703729ab..94cd379d87cfa514bec3ce32470d09d1ea8aa7d5 100644 +--- a/include/gcem_incl/max.hpp ++++ b/include/gcem_incl/max.hpp +@@ -21,6 +21,9 @@ + #ifndef _gcem_max_HPP + #define _gcem_max_HPP + ++#include ++#include ++ + /** + * Compile-time pairwise maximum function + * +@@ -35,7 +38,11 @@ common_t + max(const T1 x, const T2 y) + noexcept + { ++ if (std::is_constant_evaluated()) { + return( y < x ? x : y ); ++ } else { ++ return std::max(x, y); ++ } + } + + #endif +diff --git a/include/gcem_incl/min.hpp b/include/gcem_incl/min.hpp +index 5ce70b38e6d243267a053ec33fae31e59f6a359f..998601a4cc7864d0fc4466444a71090ad43917bd 100644 +--- a/include/gcem_incl/min.hpp ++++ b/include/gcem_incl/min.hpp +@@ -21,6 +21,9 @@ + #ifndef _gcem_min_HPP + #define _gcem_min_HPP + ++#include ++#include ++ + /** + * Compile-time pairwise minimum function + * +@@ -35,7 +38,11 @@ common_t + min(const T1 x, const T2 y) + noexcept + { ++ if (std::is_constant_evaluated()) { + return( y > x ? x : y ); ++ } else { ++ return std::min(x, y); ++ } + } + + #endif +diff --git a/include/gcem_incl/pow.hpp b/include/gcem_incl/pow.hpp +index 3891edef0e8f1e7b64e8632f46e87fd39bdba162..35b2a9aa173d4d201dbe6d642a58b0ac6b53b684 100644 +--- a/include/gcem_incl/pow.hpp ++++ b/include/gcem_incl/pow.hpp +@@ -25,6 +25,9 @@ + #ifndef _gcem_pow_HPP + #define _gcem_pow_HPP + ++#include ++#include ++ + namespace internal + { + +@@ -76,7 +79,11 @@ common_t + pow(const T1 base, const T2 exp_term) + noexcept + { ++ if (std::is_constant_evaluated()) { + return internal::pow_check(base,exp_term); ++ } else { ++ return std::pow(base, exp_term); ++ } + } + + #endif +diff --git a/include/gcem_incl/round.hpp b/include/gcem_incl/round.hpp +index 9ac4a09f0a9e7b09a303795d30ccee32ebe841b1..d7c1300b142062c4947c7df31757772f1b8c8cb0 100644 +--- a/include/gcem_incl/round.hpp ++++ b/include/gcem_incl/round.hpp +@@ -21,6 +21,9 @@ + #ifndef _gcem_round_HPP + #define _gcem_round_HPP + ++#include ++#include ++ + namespace internal + { + +@@ -119,7 +122,11 @@ return_t + round(const T x) + noexcept + { ++ if (std::is_constant_evaluated()) { + return internal::round_check( static_cast>(x) ); ++ } else { ++ return std::round(x); ++ } + } + + #endif +diff --git a/include/gcem_incl/signbit.hpp b/include/gcem_incl/signbit.hpp +index 282e24403345dccfa8bf580112c129b43df5aa6d..c13c6f3265e81c7280f4dd4db454e4262278d7a5 100644 +--- a/include/gcem_incl/signbit.hpp ++++ b/include/gcem_incl/signbit.hpp +@@ -21,6 +21,9 @@ + #ifndef _gcem_signbit_HPP + #define _gcem_signbit_HPP + ++#include ++#include ++ + /** + * Compile-time sign bit detection function + * +@@ -34,11 +37,15 @@ bool + signbit(const T x) + noexcept + { ++ if (std::is_constant_evaluated()) { + #ifdef _MSC_VER + return( (x == T(0)) ? (_fpclass(x) == _FPCLASS_NZ) : (x < T(0)) ); + #else + return GCEM_SIGNBIT(x); + #endif ++ } else { ++ return std::signbit(x); ++ } + } + + #endif +diff --git a/include/gcem_incl/sin.hpp b/include/gcem_incl/sin.hpp +index 56c8dcaf62dc22207ee7f41ec84d272e4535ab4e..203ea5d9723cc135bd024466a392aabce0896cdb 100644 +--- a/include/gcem_incl/sin.hpp ++++ b/include/gcem_incl/sin.hpp +@@ -27,6 +27,9 @@ + #ifndef _gcem_sin_HPP + #define _gcem_sin_HPP + ++#include ++#include ++ + namespace internal + { + +@@ -79,7 +82,11 @@ return_t + sin(const T x) + noexcept + { ++ if (std::is_constant_evaluated()) { + return internal::sin_check( static_cast>(x) ); ++ } else { ++ return std::sin(x); ++ } + } + + #endif +diff --git a/include/gcem_incl/sinh.hpp b/include/gcem_incl/sinh.hpp +index fe3ecdd0e719856c8bcc0e8d692d93c98c496942..337ee3d576ec4def690f8f3e2720d74a6b155744 100644 +--- a/include/gcem_incl/sinh.hpp ++++ b/include/gcem_incl/sinh.hpp +@@ -25,6 +25,9 @@ + #ifndef _gcem_sinh_HPP + #define _gcem_sinh_HPP + ++#include ++#include ++ + namespace internal + { + +@@ -59,7 +62,11 @@ return_t + sinh(const T x) + noexcept + { ++ if (std::is_constant_evaluated()) { + return internal::sinh_check( static_cast>(x) ); ++ } else { ++ return std::sinh(x); ++ } + } + + #endif +diff --git a/include/gcem_incl/sqrt.hpp b/include/gcem_incl/sqrt.hpp +index 1b2753c99ede5189fc2272080828c83ca63a184c..f65070a5ea4c8681d1d7ad99acd82644c6ddee5f 100644 +--- a/include/gcem_incl/sqrt.hpp ++++ b/include/gcem_incl/sqrt.hpp +@@ -25,6 +25,9 @@ + #ifndef _gcem_sqrt_HPP + #define _gcem_sqrt_HPP + ++#include ++#include ++ + namespace internal + { + +@@ -103,7 +106,11 @@ return_t + sqrt(const T x) + noexcept + { ++ if (std::is_constant_evaluated()) { + return internal::sqrt_check( static_cast>(x) ); ++ } else { ++ return std::sqrt(x); ++ } + } + + #endif +diff --git a/include/gcem_incl/tan.hpp b/include/gcem_incl/tan.hpp +index 386cce0f412107f65183031b3458455059f55d54..354c302a50c7a0b2b31e8288c9dab363ceac9cbe 100644 +--- a/include/gcem_incl/tan.hpp ++++ b/include/gcem_incl/tan.hpp +@@ -25,6 +25,9 @@ + #ifndef _gcem_tan_HPP + #define _gcem_tan_HPP + ++#include ++#include ++ + namespace internal + { + +@@ -134,7 +137,11 @@ return_t + tan(const T x) + noexcept + { ++ if (std::is_constant_evaluated()) { + return internal::tan_check( static_cast>(x) ); ++ } else { ++ return std::tan(x); ++ } + } + + #endif +diff --git a/include/gcem_incl/tanh.hpp b/include/gcem_incl/tanh.hpp +index 30b431886601ec9f77ca9a93a6ca62b3cabd9e57..15d47b4a258f7ac4b49164ab48058dff6db28c92 100644 +--- a/include/gcem_incl/tanh.hpp ++++ b/include/gcem_incl/tanh.hpp +@@ -25,6 +25,9 @@ + #ifndef _gcem_tanh_HPP + #define _gcem_tanh_HPP + ++#include ++#include ++ + namespace internal + { + +@@ -83,7 +86,11 @@ return_t + tanh(const T x) + noexcept + { ++ if (std::is_constant_evaluated()) { + return internal::tanh_check( static_cast>(x) ); ++ } else { ++ return std::tanh(x); ++ } + } + + #endif +diff --git a/include/gcem_incl/tgamma.hpp b/include/gcem_incl/tgamma.hpp +index deffd3a8e77c34a9ebfd5209ee32594dc5b241e2..a3bf41de5b9dc104661bbc8a574d45d587f10061 100644 +--- a/include/gcem_incl/tgamma.hpp ++++ b/include/gcem_incl/tgamma.hpp +@@ -25,6 +25,9 @@ + #ifndef _gcem_tgamma_HPP + #define _gcem_tgamma_HPP + ++#include ++#include ++ + namespace internal + { + +@@ -74,7 +77,11 @@ return_t + tgamma(const T x) + noexcept + { ++ if (std::is_constant_evaluated()) { + return internal::tgamma_check( static_cast>(x) ); ++ } else { ++ return std::tgamma(x); ++ } + } + + #endif +diff --git a/include/gcem_incl/trunc.hpp b/include/gcem_incl/trunc.hpp +index af3f448915f0f9a1b5f2d843596331f7874a6da5..979265725c95d57c66e51fe2a86de34691cbb391 100644 +--- a/include/gcem_incl/trunc.hpp ++++ b/include/gcem_incl/trunc.hpp +@@ -21,6 +21,9 @@ + #ifndef _gcem_trunc_HPP + #define _gcem_trunc_HPP + ++#include ++#include ++ + namespace internal + { + +@@ -115,7 +118,11 @@ return_t + trunc(const T x) + noexcept + { ++ if (std::is_constant_evaluated()) { + return internal::trunc_check( static_cast>(x) ); ++ } else { ++ return std::trunc(x); ++ } + } + + #endif diff --git a/upstream_utils/update_gcem.py b/upstream_utils/update_gcem.py index 0f3fe1f7b9..cc123d495b 100755 --- a/upstream_utils/update_gcem.py +++ b/upstream_utils/update_gcem.py @@ -19,7 +19,7 @@ def main(): # Apply patches to upstream Git repo os.chdir(upstream_root) - for f in []: + for f in ["0001-Call-std-functions-if-not-constant-evaluated.patch"]: git_am(os.path.join(wpilib_root, "upstream_utils/gcem_patches", f)) # Delete old install diff --git a/wpimath/src/main/native/include/frc/geometry/Rotation2d.inc b/wpimath/src/main/native/include/frc/geometry/Rotation2d.inc index dbe9e3596e..0d9e97d497 100644 --- a/wpimath/src/main/native/include/frc/geometry/Rotation2d.inc +++ b/wpimath/src/main/native/include/frc/geometry/Rotation2d.inc @@ -4,27 +4,23 @@ #pragma once -#include +#include #include "frc/geometry/Rotation2d.h" -#include "gcem.hpp" #include "units/angle.h" namespace frc { constexpr Rotation2d::Rotation2d(units::radian_t value) : m_value(value), - m_cos(std::is_constant_evaluated() ? gcem::cos(value.to()) - : std::cos(value.to())), - m_sin(std::is_constant_evaluated() ? gcem::sin(value.to()) - : std::sin(value.to())) {} + m_cos(gcem::cos(value.to())), + m_sin(gcem::sin(value.to())) {} constexpr Rotation2d::Rotation2d(units::degree_t value) : Rotation2d(units::radian_t{value}) {} constexpr Rotation2d::Rotation2d(double x, double y) { - double magnitude = - std::is_constant_evaluated() ? gcem::hypot(x, y) : std::hypot(x, y); + double magnitude = gcem::hypot(x, y); if (magnitude > 1e-6) { m_sin = y / magnitude; m_cos = x / magnitude; @@ -32,9 +28,7 @@ constexpr Rotation2d::Rotation2d(double x, double y) { m_sin = 0.0; m_cos = 1.0; } - m_value = - units::radian_t{std::is_constant_evaluated() ? gcem::atan2(m_sin, m_cos) - : std::atan2(m_sin, m_cos)}; + m_value = units::radian_t{gcem::atan2(m_sin, m_cos)}; } constexpr Rotation2d Rotation2d::operator-() const { @@ -58,9 +52,7 @@ constexpr Rotation2d Rotation2d::operator/(double scalar) const { } constexpr bool Rotation2d::operator==(const Rotation2d& other) const { - return (std::is_constant_evaluated() - ? gcem::hypot(Cos() - other.Cos(), Sin() - other.Sin()) - : std::hypot(Cos() - other.Cos(), Sin() - other.Sin())) < 1E-9; + return gcem::hypot(Cos() - other.Cos(), Sin() - other.Sin()) < 1E-9; } constexpr Rotation2d Rotation2d::RotateBy(const Rotation2d& other) const { diff --git a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/abs.hpp b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/abs.hpp index 6d7b66d91b..32ee89494c 100644 --- a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/abs.hpp +++ b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/abs.hpp @@ -21,6 +21,9 @@ #ifndef _gcem_abs_HPP #define _gcem_abs_HPP +#include +#include + /** * Compile-time absolute value function * @@ -34,12 +37,16 @@ T abs(const T x) noexcept { + if (std::is_constant_evaluated()) { return( // deal with signed-zeros x == T(0) ? \ T(0) : // else x < T(0) ? \ - x : x ); + } else { + return std::abs(x); + } } #endif diff --git a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/acos.hpp b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/acos.hpp index a47003d61d..c40006de7f 100644 --- a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/acos.hpp +++ b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/acos.hpp @@ -25,6 +25,9 @@ #ifndef _gcem_acos_HPP #define _gcem_acos_HPP +#include +#include + namespace internal { @@ -78,7 +81,11 @@ return_t acos(const T x) noexcept { + if (std::is_constant_evaluated()) { return internal::acos_check( static_cast>(x) ); + } else { + return std::acos(x); + } } #endif diff --git a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/acosh.hpp b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/acosh.hpp index 8767200778..edf71db655 100644 --- a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/acosh.hpp +++ b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/acosh.hpp @@ -25,6 +25,9 @@ #ifndef _gcem_acosh_HPP #define _gcem_acosh_HPP +#include +#include + namespace internal { @@ -62,7 +65,11 @@ return_t acosh(const T x) noexcept { + if (std::is_constant_evaluated()) { return internal::acosh_compute( static_cast>(x) ); + } else { + return std::acosh(x); + } } #endif diff --git a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/asin.hpp b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/asin.hpp index 6a79e87df4..57840d4b1a 100644 --- a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/asin.hpp +++ b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/asin.hpp @@ -25,6 +25,9 @@ #ifndef _gcem_asin_HPP #define _gcem_asin_HPP +#include +#include + namespace internal { @@ -76,7 +79,11 @@ return_t asin(const T x) noexcept { + if (std::is_constant_evaluated()) { return internal::asin_check( static_cast>(x) ); + } else { + return std::asin(x); + } } #endif diff --git a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/asinh.hpp b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/asinh.hpp index a5f3ff62a0..7e5190289a 100644 --- a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/asinh.hpp +++ b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/asinh.hpp @@ -25,6 +25,9 @@ #ifndef _gcem_asinh_HPP #define _gcem_asinh_HPP +#include +#include + namespace internal { @@ -59,7 +62,11 @@ return_t asinh(const T x) noexcept { + if (std::is_constant_evaluated()) { return internal::asinh_compute( static_cast>(x) ); + } else { + return std::asinh(x); + } } diff --git a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/atan.hpp b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/atan.hpp index 3f46974c07..9ebd33e65d 100644 --- a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/atan.hpp +++ b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/atan.hpp @@ -29,6 +29,9 @@ #ifndef _gcem_atan_HPP #define _gcem_atan_HPP +#include +#include + namespace internal { @@ -149,7 +152,11 @@ return_t atan(const T x) noexcept { + if (std::is_constant_evaluated()) { return internal::atan_check( static_cast>(x) ); + } else { + return std::atan(x); + } } #endif diff --git a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/atan2.hpp b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/atan2.hpp index 5ca55b79c8..d3abcd88c9 100644 --- a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/atan2.hpp +++ b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/atan2.hpp @@ -25,6 +25,9 @@ #ifndef _gcem_atan2_HPP #define _gcem_atan2_HPP +#include +#include + namespace internal { @@ -82,7 +85,11 @@ common_return_t atan2(const T1 y, const T2 x) noexcept { + if (std::is_constant_evaluated()) { return internal::atan2_type_check(x,y); + } else { + return std::atan2(y, x); + } } #endif diff --git a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/atanh.hpp b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/atanh.hpp index dfb4dc312d..753d469857 100644 --- a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/atanh.hpp +++ b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/atanh.hpp @@ -25,6 +25,9 @@ #ifndef _gcem_atanh_HPP #define _gcem_atanh_HPP +#include +#include + namespace internal { @@ -73,7 +76,11 @@ return_t atanh(const T x) noexcept { + if (std::is_constant_evaluated()) { return internal::atanh_check( static_cast>(x) ); + } else { + return std::atanh(x); + } } #endif diff --git a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/beta.hpp b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/beta.hpp index e43d4fcd9a..b7da514a25 100644 --- a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/beta.hpp +++ b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/beta.hpp @@ -21,6 +21,9 @@ #ifndef _gcem_beta_HPP #define _gcem_beta_HPP +#include +#include + /** * Compile-time beta function * @@ -36,7 +39,15 @@ common_return_t beta(const T1 a, const T2 b) noexcept { + if (std::is_constant_evaluated()) { return exp( lbeta(a,b) ); + } else { +#ifdef __cpp_lib_math_special_functions + return std::beta(a, b); +#else + return exp( lbeta(a,b) ); +#endif + } } #endif diff --git a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/ceil.hpp b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/ceil.hpp index ff1097bac2..257ff0550c 100644 --- a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/ceil.hpp +++ b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/ceil.hpp @@ -21,6 +21,9 @@ #ifndef _gcem_ceil_HPP #define _gcem_ceil_HPP +#include +#include + namespace internal { @@ -124,7 +127,11 @@ return_t ceil(const T x) noexcept { + if (std::is_constant_evaluated()) { return internal::ceil_check( static_cast>(x) ); + } else { + return std::ceil(x); + } } #endif diff --git a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/copysign.hpp b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/copysign.hpp index c1741f7f32..eecfea21a2 100644 --- a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/copysign.hpp +++ b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/copysign.hpp @@ -21,6 +21,9 @@ #ifndef _gcem_copysign_HPP #define _gcem_copysign_HPP +#include +#include + /** * Compile-time copy sign function * @@ -35,7 +38,11 @@ T1 copysign(const T1 x, const T2 y) noexcept { + if (std::is_constant_evaluated()) { return( signbit(x) != signbit(y) ? -x : x ); + } else { + return std::copysign(x, y); + } } #endif diff --git a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/cos.hpp b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/cos.hpp index 82f4c609f5..9c8181bb99 100644 --- a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/cos.hpp +++ b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/cos.hpp @@ -25,6 +25,9 @@ #ifndef _gcem_cos_HPP #define _gcem_cos_HPP +#include +#include + namespace internal { @@ -77,7 +80,11 @@ return_t cos(const T x) noexcept { + if (std::is_constant_evaluated()) { return internal::cos_check( static_cast>(x) ); + } else { + return std::cos(x); + } } #endif diff --git a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/cosh.hpp b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/cosh.hpp index fc89c0d064..225c37a011 100644 --- a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/cosh.hpp +++ b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/cosh.hpp @@ -25,6 +25,9 @@ #ifndef _gcem_cosh_HPP #define _gcem_cosh_HPP +#include +#include + namespace internal { @@ -59,7 +62,11 @@ return_t cosh(const T x) noexcept { + if (std::is_constant_evaluated()) { return internal::cosh_compute( static_cast>(x) ); + } else { + return std::cosh(x); + } } #endif diff --git a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/erf.hpp b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/erf.hpp index d0bc83ada1..ee5386325b 100644 --- a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/erf.hpp +++ b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/erf.hpp @@ -25,6 +25,9 @@ #ifndef _gcem_erf_HPP #define _gcem_erf_HPP +#include +#include + namespace internal { @@ -137,7 +140,11 @@ return_t erf(const T x) noexcept { + if (std::is_constant_evaluated()) { return internal::erf_check( static_cast>(x) ); + } else { + return std::erf(x); + } } #endif diff --git a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/exp.hpp b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/exp.hpp index 595ffc2a62..acbda39377 100644 --- a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/exp.hpp +++ b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/exp.hpp @@ -25,6 +25,9 @@ #ifndef _gcem_exp_HPP #define _gcem_exp_HPP +#include +#include + namespace internal { @@ -124,7 +127,11 @@ return_t exp(const T x) noexcept { + if (std::is_constant_evaluated()) { return internal::exp_check( static_cast>(x) ); + } else { + return std::exp(x); + } } #endif diff --git a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/expm1.hpp b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/expm1.hpp index 70c9ecf5a4..edecd394cf 100644 --- a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/expm1.hpp +++ b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/expm1.hpp @@ -25,6 +25,9 @@ #ifndef _gcem_expm1_HPP #define _gcem_expm1_HPP +#include +#include + namespace internal { @@ -70,7 +73,11 @@ return_t expm1(const T x) noexcept { + if (std::is_constant_evaluated()) { return internal::expm1_check( static_cast>(x) ); + } else { + return std::expm1(x); + } } #endif diff --git a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/floor.hpp b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/floor.hpp index 8b260ff8a1..e35592a391 100644 --- a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/floor.hpp +++ b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/floor.hpp @@ -21,6 +21,9 @@ #ifndef _gcem_floor_HPP #define _gcem_floor_HPP +#include +#include + namespace internal { @@ -124,7 +127,11 @@ return_t floor(const T x) noexcept { + if (std::is_constant_evaluated()) { return internal::floor_check( static_cast>(x) ); + } else { + return std::floor(x); + } } #endif diff --git a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/fmod.hpp b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/fmod.hpp index 02459efd4b..2f503140e3 100644 --- a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/fmod.hpp +++ b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/fmod.hpp @@ -21,6 +21,9 @@ #ifndef _gcem_fmod_HPP #define _gcem_fmod_HPP +#include +#include + namespace internal { @@ -64,7 +67,11 @@ common_return_t fmod(const T1 x, const T2 y) noexcept { + if (std::is_constant_evaluated()) { return internal::fmod_type_check(x,y); + } else { + return std::fmod(x, y); + } } #endif diff --git a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/hypot.hpp b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/hypot.hpp index 01ad4e9212..c51a5b42e5 100644 --- a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/hypot.hpp +++ b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/hypot.hpp @@ -27,6 +27,9 @@ #ifndef _gcem_hypot_HPP #define _gcem_hypot_HPP +#include +#include + namespace internal { @@ -84,7 +87,11 @@ common_return_t hypot(const T1 x, const T2 y) noexcept { + if (std::is_constant_evaluated()) { return internal::hypot_type_check(x,y); + } else { + return std::hypot(x, y); + } } #endif diff --git a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/lgamma.hpp b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/lgamma.hpp index 507c6d4c91..7c11fe56ad 100644 --- a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/lgamma.hpp +++ b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/lgamma.hpp @@ -28,6 +28,9 @@ #ifndef _gcem_lgamma_HPP #define _gcem_lgamma_HPP +#include +#include + namespace internal { @@ -129,7 +132,11 @@ return_t lgamma(const T x) noexcept { + if (std::is_constant_evaluated()) { return internal::lgamma_check( static_cast>(x) ); + } else { + return std::lgamma(x); + } } #endif diff --git a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/log.hpp b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/log.hpp index c2e24b006c..b9f1f02ced 100644 --- a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/log.hpp +++ b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/log.hpp @@ -25,6 +25,9 @@ #ifndef _gcem_log_HPP #define _gcem_log_HPP +#include +#include + namespace internal { @@ -180,7 +183,11 @@ return_t log(const T x) noexcept { + if (std::is_constant_evaluated()) { return internal::log_integral_check( x ); + } else { + return std::log(x); + } } #endif diff --git a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/log10.hpp b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/log10.hpp index cda8894fdd..0d4ff3ecb0 100644 --- a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/log10.hpp +++ b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/log10.hpp @@ -25,6 +25,9 @@ #ifndef _gcem_log10_HPP #define _gcem_log10_HPP +#include +#include + namespace internal { @@ -53,7 +56,11 @@ return_t log10(const T x) noexcept { + if (std::is_constant_evaluated()) { return internal::log10_check( x ); + } else { + return std::log10(x); + } } #endif diff --git a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/log1p.hpp b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/log1p.hpp index ccd08b8cb8..b7e6cd534d 100644 --- a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/log1p.hpp +++ b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/log1p.hpp @@ -25,6 +25,9 @@ #ifndef _gcem_log1p_HPP #define _gcem_log1p_HPP +#include +#include + namespace internal { @@ -74,7 +77,11 @@ return_t log1p(const T x) noexcept { + if (std::is_constant_evaluated()) { return internal::log1p_check( static_cast>(x) ); + } else { + return std::log1p(x); + } } #endif diff --git a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/log2.hpp b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/log2.hpp index a97fed4c72..37196152d0 100644 --- a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/log2.hpp +++ b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/log2.hpp @@ -25,6 +25,9 @@ #ifndef _gcem_log2_HPP #define _gcem_log2_HPP +#include +#include + namespace internal { @@ -53,7 +56,11 @@ return_t log2(const T x) noexcept { + if (std::is_constant_evaluated()) { return internal::log2_check( x ); + } else { + return std::log2(x); + } } #endif diff --git a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/max.hpp b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/max.hpp index ddc3e4e6ca..94cd379d87 100644 --- a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/max.hpp +++ b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/max.hpp @@ -21,6 +21,9 @@ #ifndef _gcem_max_HPP #define _gcem_max_HPP +#include +#include + /** * Compile-time pairwise maximum function * @@ -35,7 +38,11 @@ common_t max(const T1 x, const T2 y) noexcept { + if (std::is_constant_evaluated()) { return( y < x ? x : y ); + } else { + return std::max(x, y); + } } #endif diff --git a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/min.hpp b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/min.hpp index 5ce70b38e6..998601a4cc 100644 --- a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/min.hpp +++ b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/min.hpp @@ -21,6 +21,9 @@ #ifndef _gcem_min_HPP #define _gcem_min_HPP +#include +#include + /** * Compile-time pairwise minimum function * @@ -35,7 +38,11 @@ common_t min(const T1 x, const T2 y) noexcept { + if (std::is_constant_evaluated()) { return( y > x ? x : y ); + } else { + return std::min(x, y); + } } #endif diff --git a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/pow.hpp b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/pow.hpp index 3891edef0e..35b2a9aa17 100644 --- a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/pow.hpp +++ b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/pow.hpp @@ -25,6 +25,9 @@ #ifndef _gcem_pow_HPP #define _gcem_pow_HPP +#include +#include + namespace internal { @@ -76,7 +79,11 @@ common_t pow(const T1 base, const T2 exp_term) noexcept { + if (std::is_constant_evaluated()) { return internal::pow_check(base,exp_term); + } else { + return std::pow(base, exp_term); + } } #endif diff --git a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/round.hpp b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/round.hpp index 9ac4a09f0a..d7c1300b14 100644 --- a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/round.hpp +++ b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/round.hpp @@ -21,6 +21,9 @@ #ifndef _gcem_round_HPP #define _gcem_round_HPP +#include +#include + namespace internal { @@ -119,7 +122,11 @@ return_t round(const T x) noexcept { + if (std::is_constant_evaluated()) { return internal::round_check( static_cast>(x) ); + } else { + return std::round(x); + } } #endif diff --git a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/signbit.hpp b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/signbit.hpp index 282e244033..c13c6f3265 100644 --- a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/signbit.hpp +++ b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/signbit.hpp @@ -21,6 +21,9 @@ #ifndef _gcem_signbit_HPP #define _gcem_signbit_HPP +#include +#include + /** * Compile-time sign bit detection function * @@ -34,11 +37,15 @@ bool signbit(const T x) noexcept { + if (std::is_constant_evaluated()) { #ifdef _MSC_VER return( (x == T(0)) ? (_fpclass(x) == _FPCLASS_NZ) : (x < T(0)) ); #else return GCEM_SIGNBIT(x); #endif + } else { + return std::signbit(x); + } } #endif diff --git a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/sin.hpp b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/sin.hpp index 56c8dcaf62..203ea5d972 100644 --- a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/sin.hpp +++ b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/sin.hpp @@ -27,6 +27,9 @@ #ifndef _gcem_sin_HPP #define _gcem_sin_HPP +#include +#include + namespace internal { @@ -79,7 +82,11 @@ return_t sin(const T x) noexcept { + if (std::is_constant_evaluated()) { return internal::sin_check( static_cast>(x) ); + } else { + return std::sin(x); + } } #endif diff --git a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/sinh.hpp b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/sinh.hpp index fe3ecdd0e7..337ee3d576 100644 --- a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/sinh.hpp +++ b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/sinh.hpp @@ -25,6 +25,9 @@ #ifndef _gcem_sinh_HPP #define _gcem_sinh_HPP +#include +#include + namespace internal { @@ -59,7 +62,11 @@ return_t sinh(const T x) noexcept { + if (std::is_constant_evaluated()) { return internal::sinh_check( static_cast>(x) ); + } else { + return std::sinh(x); + } } #endif diff --git a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/sqrt.hpp b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/sqrt.hpp index 1b2753c99e..f65070a5ea 100644 --- a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/sqrt.hpp +++ b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/sqrt.hpp @@ -25,6 +25,9 @@ #ifndef _gcem_sqrt_HPP #define _gcem_sqrt_HPP +#include +#include + namespace internal { @@ -103,7 +106,11 @@ return_t sqrt(const T x) noexcept { + if (std::is_constant_evaluated()) { return internal::sqrt_check( static_cast>(x) ); + } else { + return std::sqrt(x); + } } #endif diff --git a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/tan.hpp b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/tan.hpp index 386cce0f41..354c302a50 100644 --- a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/tan.hpp +++ b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/tan.hpp @@ -25,6 +25,9 @@ #ifndef _gcem_tan_HPP #define _gcem_tan_HPP +#include +#include + namespace internal { @@ -134,7 +137,11 @@ return_t tan(const T x) noexcept { + if (std::is_constant_evaluated()) { return internal::tan_check( static_cast>(x) ); + } else { + return std::tan(x); + } } #endif diff --git a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/tanh.hpp b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/tanh.hpp index 30b4318866..15d47b4a25 100644 --- a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/tanh.hpp +++ b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/tanh.hpp @@ -25,6 +25,9 @@ #ifndef _gcem_tanh_HPP #define _gcem_tanh_HPP +#include +#include + namespace internal { @@ -83,7 +86,11 @@ return_t tanh(const T x) noexcept { + if (std::is_constant_evaluated()) { return internal::tanh_check( static_cast>(x) ); + } else { + return std::tanh(x); + } } #endif diff --git a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/tgamma.hpp b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/tgamma.hpp index deffd3a8e7..a3bf41de5b 100644 --- a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/tgamma.hpp +++ b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/tgamma.hpp @@ -25,6 +25,9 @@ #ifndef _gcem_tgamma_HPP #define _gcem_tgamma_HPP +#include +#include + namespace internal { @@ -74,7 +77,11 @@ return_t tgamma(const T x) noexcept { + if (std::is_constant_evaluated()) { return internal::tgamma_check( static_cast>(x) ); + } else { + return std::tgamma(x); + } } #endif diff --git a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/trunc.hpp b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/trunc.hpp index af3f448915..979265725c 100644 --- a/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/trunc.hpp +++ b/wpimath/src/main/native/thirdparty/gcem/include/gcem_incl/trunc.hpp @@ -21,6 +21,9 @@ #ifndef _gcem_trunc_HPP #define _gcem_trunc_HPP +#include +#include + namespace internal { @@ -115,7 +118,11 @@ return_t trunc(const T x) noexcept { + if (std::is_constant_evaluated()) { return internal::trunc_check( static_cast>(x) ); + } else { + return std::trunc(x); + } } #endif