mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-27 02:01:42 +00:00
[wpimath] Make gcem call std functions if not constant-evaluated (#5983)
The one exception is macOS, which doesn't support std::beta().
This commit is contained in:
@@ -4,27 +4,23 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <type_traits>
|
||||
#include <gcem.hpp>
|
||||
|
||||
#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<double>())
|
||||
: std::cos(value.to<double>())),
|
||||
m_sin(std::is_constant_evaluated() ? gcem::sin(value.to<double>())
|
||||
: std::sin(value.to<double>())) {}
|
||||
m_cos(gcem::cos(value.to<double>())),
|
||||
m_sin(gcem::sin(value.to<double>())) {}
|
||||
|
||||
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 {
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
#ifndef _gcem_abs_HPP
|
||||
#define _gcem_abs_HPP
|
||||
|
||||
#include <cmath>
|
||||
#include <type_traits>
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
#ifndef _gcem_acos_HPP
|
||||
#define _gcem_acos_HPP
|
||||
|
||||
#include <cmath>
|
||||
#include <type_traits>
|
||||
|
||||
namespace internal
|
||||
{
|
||||
|
||||
@@ -78,7 +81,11 @@ return_t<T>
|
||||
acos(const T x)
|
||||
noexcept
|
||||
{
|
||||
if (std::is_constant_evaluated()) {
|
||||
return internal::acos_check( static_cast<return_t<T>>(x) );
|
||||
} else {
|
||||
return std::acos(x);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
#ifndef _gcem_acosh_HPP
|
||||
#define _gcem_acosh_HPP
|
||||
|
||||
#include <cmath>
|
||||
#include <type_traits>
|
||||
|
||||
namespace internal
|
||||
{
|
||||
|
||||
@@ -62,7 +65,11 @@ return_t<T>
|
||||
acosh(const T x)
|
||||
noexcept
|
||||
{
|
||||
if (std::is_constant_evaluated()) {
|
||||
return internal::acosh_compute( static_cast<return_t<T>>(x) );
|
||||
} else {
|
||||
return std::acosh(x);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
#ifndef _gcem_asin_HPP
|
||||
#define _gcem_asin_HPP
|
||||
|
||||
#include <cmath>
|
||||
#include <type_traits>
|
||||
|
||||
namespace internal
|
||||
{
|
||||
|
||||
@@ -76,7 +79,11 @@ return_t<T>
|
||||
asin(const T x)
|
||||
noexcept
|
||||
{
|
||||
if (std::is_constant_evaluated()) {
|
||||
return internal::asin_check( static_cast<return_t<T>>(x) );
|
||||
} else {
|
||||
return std::asin(x);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
#ifndef _gcem_asinh_HPP
|
||||
#define _gcem_asinh_HPP
|
||||
|
||||
#include <cmath>
|
||||
#include <type_traits>
|
||||
|
||||
namespace internal
|
||||
{
|
||||
|
||||
@@ -59,7 +62,11 @@ return_t<T>
|
||||
asinh(const T x)
|
||||
noexcept
|
||||
{
|
||||
if (std::is_constant_evaluated()) {
|
||||
return internal::asinh_compute( static_cast<return_t<T>>(x) );
|
||||
} else {
|
||||
return std::asinh(x);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -29,6 +29,9 @@
|
||||
#ifndef _gcem_atan_HPP
|
||||
#define _gcem_atan_HPP
|
||||
|
||||
#include <cmath>
|
||||
#include <type_traits>
|
||||
|
||||
namespace internal
|
||||
{
|
||||
|
||||
@@ -149,7 +152,11 @@ return_t<T>
|
||||
atan(const T x)
|
||||
noexcept
|
||||
{
|
||||
if (std::is_constant_evaluated()) {
|
||||
return internal::atan_check( static_cast<return_t<T>>(x) );
|
||||
} else {
|
||||
return std::atan(x);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
#ifndef _gcem_atan2_HPP
|
||||
#define _gcem_atan2_HPP
|
||||
|
||||
#include <cmath>
|
||||
#include <type_traits>
|
||||
|
||||
namespace internal
|
||||
{
|
||||
|
||||
@@ -82,7 +85,11 @@ common_return_t<T1,T2>
|
||||
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
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
#ifndef _gcem_atanh_HPP
|
||||
#define _gcem_atanh_HPP
|
||||
|
||||
#include <cmath>
|
||||
#include <type_traits>
|
||||
|
||||
namespace internal
|
||||
{
|
||||
|
||||
@@ -73,7 +76,11 @@ return_t<T>
|
||||
atanh(const T x)
|
||||
noexcept
|
||||
{
|
||||
if (std::is_constant_evaluated()) {
|
||||
return internal::atanh_check( static_cast<return_t<T>>(x) );
|
||||
} else {
|
||||
return std::atanh(x);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
#ifndef _gcem_beta_HPP
|
||||
#define _gcem_beta_HPP
|
||||
|
||||
#include <cmath>
|
||||
#include <type_traits>
|
||||
|
||||
/**
|
||||
* Compile-time beta function
|
||||
*
|
||||
@@ -36,7 +39,15 @@ common_return_t<T1,T2>
|
||||
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
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
#ifndef _gcem_ceil_HPP
|
||||
#define _gcem_ceil_HPP
|
||||
|
||||
#include <cmath>
|
||||
#include <type_traits>
|
||||
|
||||
namespace internal
|
||||
{
|
||||
|
||||
@@ -124,7 +127,11 @@ return_t<T>
|
||||
ceil(const T x)
|
||||
noexcept
|
||||
{
|
||||
if (std::is_constant_evaluated()) {
|
||||
return internal::ceil_check( static_cast<return_t<T>>(x) );
|
||||
} else {
|
||||
return std::ceil(x);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
#ifndef _gcem_copysign_HPP
|
||||
#define _gcem_copysign_HPP
|
||||
|
||||
#include <cmath>
|
||||
#include <type_traits>
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
#ifndef _gcem_cos_HPP
|
||||
#define _gcem_cos_HPP
|
||||
|
||||
#include <cmath>
|
||||
#include <type_traits>
|
||||
|
||||
namespace internal
|
||||
{
|
||||
|
||||
@@ -77,7 +80,11 @@ return_t<T>
|
||||
cos(const T x)
|
||||
noexcept
|
||||
{
|
||||
if (std::is_constant_evaluated()) {
|
||||
return internal::cos_check( static_cast<return_t<T>>(x) );
|
||||
} else {
|
||||
return std::cos(x);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
#ifndef _gcem_cosh_HPP
|
||||
#define _gcem_cosh_HPP
|
||||
|
||||
#include <cmath>
|
||||
#include <type_traits>
|
||||
|
||||
namespace internal
|
||||
{
|
||||
|
||||
@@ -59,7 +62,11 @@ return_t<T>
|
||||
cosh(const T x)
|
||||
noexcept
|
||||
{
|
||||
if (std::is_constant_evaluated()) {
|
||||
return internal::cosh_compute( static_cast<return_t<T>>(x) );
|
||||
} else {
|
||||
return std::cosh(x);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
#ifndef _gcem_erf_HPP
|
||||
#define _gcem_erf_HPP
|
||||
|
||||
#include <cmath>
|
||||
#include <type_traits>
|
||||
|
||||
namespace internal
|
||||
{
|
||||
|
||||
@@ -137,7 +140,11 @@ return_t<T>
|
||||
erf(const T x)
|
||||
noexcept
|
||||
{
|
||||
if (std::is_constant_evaluated()) {
|
||||
return internal::erf_check( static_cast<return_t<T>>(x) );
|
||||
} else {
|
||||
return std::erf(x);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
#ifndef _gcem_exp_HPP
|
||||
#define _gcem_exp_HPP
|
||||
|
||||
#include <cmath>
|
||||
#include <type_traits>
|
||||
|
||||
namespace internal
|
||||
{
|
||||
|
||||
@@ -124,7 +127,11 @@ return_t<T>
|
||||
exp(const T x)
|
||||
noexcept
|
||||
{
|
||||
if (std::is_constant_evaluated()) {
|
||||
return internal::exp_check( static_cast<return_t<T>>(x) );
|
||||
} else {
|
||||
return std::exp(x);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
#ifndef _gcem_expm1_HPP
|
||||
#define _gcem_expm1_HPP
|
||||
|
||||
#include <cmath>
|
||||
#include <type_traits>
|
||||
|
||||
namespace internal
|
||||
{
|
||||
|
||||
@@ -70,7 +73,11 @@ return_t<T>
|
||||
expm1(const T x)
|
||||
noexcept
|
||||
{
|
||||
if (std::is_constant_evaluated()) {
|
||||
return internal::expm1_check( static_cast<return_t<T>>(x) );
|
||||
} else {
|
||||
return std::expm1(x);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
#ifndef _gcem_floor_HPP
|
||||
#define _gcem_floor_HPP
|
||||
|
||||
#include <cmath>
|
||||
#include <type_traits>
|
||||
|
||||
namespace internal
|
||||
{
|
||||
|
||||
@@ -124,7 +127,11 @@ return_t<T>
|
||||
floor(const T x)
|
||||
noexcept
|
||||
{
|
||||
if (std::is_constant_evaluated()) {
|
||||
return internal::floor_check( static_cast<return_t<T>>(x) );
|
||||
} else {
|
||||
return std::floor(x);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
#ifndef _gcem_fmod_HPP
|
||||
#define _gcem_fmod_HPP
|
||||
|
||||
#include <cmath>
|
||||
#include <type_traits>
|
||||
|
||||
namespace internal
|
||||
{
|
||||
|
||||
@@ -64,7 +67,11 @@ common_return_t<T1,T2>
|
||||
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
|
||||
|
||||
@@ -27,6 +27,9 @@
|
||||
#ifndef _gcem_hypot_HPP
|
||||
#define _gcem_hypot_HPP
|
||||
|
||||
#include <cmath>
|
||||
#include <type_traits>
|
||||
|
||||
namespace internal
|
||||
{
|
||||
|
||||
@@ -84,7 +87,11 @@ common_return_t<T1,T2>
|
||||
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
|
||||
|
||||
@@ -28,6 +28,9 @@
|
||||
#ifndef _gcem_lgamma_HPP
|
||||
#define _gcem_lgamma_HPP
|
||||
|
||||
#include <cmath>
|
||||
#include <type_traits>
|
||||
|
||||
namespace internal
|
||||
{
|
||||
|
||||
@@ -129,7 +132,11 @@ return_t<T>
|
||||
lgamma(const T x)
|
||||
noexcept
|
||||
{
|
||||
if (std::is_constant_evaluated()) {
|
||||
return internal::lgamma_check( static_cast<return_t<T>>(x) );
|
||||
} else {
|
||||
return std::lgamma(x);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
#ifndef _gcem_log_HPP
|
||||
#define _gcem_log_HPP
|
||||
|
||||
#include <cmath>
|
||||
#include <type_traits>
|
||||
|
||||
namespace internal
|
||||
{
|
||||
|
||||
@@ -180,7 +183,11 @@ return_t<T>
|
||||
log(const T x)
|
||||
noexcept
|
||||
{
|
||||
if (std::is_constant_evaluated()) {
|
||||
return internal::log_integral_check( x );
|
||||
} else {
|
||||
return std::log(x);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
#ifndef _gcem_log10_HPP
|
||||
#define _gcem_log10_HPP
|
||||
|
||||
#include <cmath>
|
||||
#include <type_traits>
|
||||
|
||||
namespace internal
|
||||
{
|
||||
|
||||
@@ -53,7 +56,11 @@ return_t<T>
|
||||
log10(const T x)
|
||||
noexcept
|
||||
{
|
||||
if (std::is_constant_evaluated()) {
|
||||
return internal::log10_check( x );
|
||||
} else {
|
||||
return std::log10(x);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
#ifndef _gcem_log1p_HPP
|
||||
#define _gcem_log1p_HPP
|
||||
|
||||
#include <cmath>
|
||||
#include <type_traits>
|
||||
|
||||
namespace internal
|
||||
{
|
||||
|
||||
@@ -74,7 +77,11 @@ return_t<T>
|
||||
log1p(const T x)
|
||||
noexcept
|
||||
{
|
||||
if (std::is_constant_evaluated()) {
|
||||
return internal::log1p_check( static_cast<return_t<T>>(x) );
|
||||
} else {
|
||||
return std::log1p(x);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
#ifndef _gcem_log2_HPP
|
||||
#define _gcem_log2_HPP
|
||||
|
||||
#include <cmath>
|
||||
#include <type_traits>
|
||||
|
||||
namespace internal
|
||||
{
|
||||
|
||||
@@ -53,7 +56,11 @@ return_t<T>
|
||||
log2(const T x)
|
||||
noexcept
|
||||
{
|
||||
if (std::is_constant_evaluated()) {
|
||||
return internal::log2_check( x );
|
||||
} else {
|
||||
return std::log2(x);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
#ifndef _gcem_max_HPP
|
||||
#define _gcem_max_HPP
|
||||
|
||||
#include <cmath>
|
||||
#include <type_traits>
|
||||
|
||||
/**
|
||||
* Compile-time pairwise maximum function
|
||||
*
|
||||
@@ -35,7 +38,11 @@ common_t<T1,T2>
|
||||
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
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
#ifndef _gcem_min_HPP
|
||||
#define _gcem_min_HPP
|
||||
|
||||
#include <cmath>
|
||||
#include <type_traits>
|
||||
|
||||
/**
|
||||
* Compile-time pairwise minimum function
|
||||
*
|
||||
@@ -35,7 +38,11 @@ common_t<T1,T2>
|
||||
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
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
#ifndef _gcem_pow_HPP
|
||||
#define _gcem_pow_HPP
|
||||
|
||||
#include <cmath>
|
||||
#include <type_traits>
|
||||
|
||||
namespace internal
|
||||
{
|
||||
|
||||
@@ -76,7 +79,11 @@ common_t<T1,T2>
|
||||
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
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
#ifndef _gcem_round_HPP
|
||||
#define _gcem_round_HPP
|
||||
|
||||
#include <cmath>
|
||||
#include <type_traits>
|
||||
|
||||
namespace internal
|
||||
{
|
||||
|
||||
@@ -119,7 +122,11 @@ return_t<T>
|
||||
round(const T x)
|
||||
noexcept
|
||||
{
|
||||
if (std::is_constant_evaluated()) {
|
||||
return internal::round_check( static_cast<return_t<T>>(x) );
|
||||
} else {
|
||||
return std::round(x);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
#ifndef _gcem_signbit_HPP
|
||||
#define _gcem_signbit_HPP
|
||||
|
||||
#include <cmath>
|
||||
#include <type_traits>
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
||||
@@ -27,6 +27,9 @@
|
||||
#ifndef _gcem_sin_HPP
|
||||
#define _gcem_sin_HPP
|
||||
|
||||
#include <cmath>
|
||||
#include <type_traits>
|
||||
|
||||
namespace internal
|
||||
{
|
||||
|
||||
@@ -79,7 +82,11 @@ return_t<T>
|
||||
sin(const T x)
|
||||
noexcept
|
||||
{
|
||||
if (std::is_constant_evaluated()) {
|
||||
return internal::sin_check( static_cast<return_t<T>>(x) );
|
||||
} else {
|
||||
return std::sin(x);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
#ifndef _gcem_sinh_HPP
|
||||
#define _gcem_sinh_HPP
|
||||
|
||||
#include <cmath>
|
||||
#include <type_traits>
|
||||
|
||||
namespace internal
|
||||
{
|
||||
|
||||
@@ -59,7 +62,11 @@ return_t<T>
|
||||
sinh(const T x)
|
||||
noexcept
|
||||
{
|
||||
if (std::is_constant_evaluated()) {
|
||||
return internal::sinh_check( static_cast<return_t<T>>(x) );
|
||||
} else {
|
||||
return std::sinh(x);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
#ifndef _gcem_sqrt_HPP
|
||||
#define _gcem_sqrt_HPP
|
||||
|
||||
#include <cmath>
|
||||
#include <type_traits>
|
||||
|
||||
namespace internal
|
||||
{
|
||||
|
||||
@@ -103,7 +106,11 @@ return_t<T>
|
||||
sqrt(const T x)
|
||||
noexcept
|
||||
{
|
||||
if (std::is_constant_evaluated()) {
|
||||
return internal::sqrt_check( static_cast<return_t<T>>(x) );
|
||||
} else {
|
||||
return std::sqrt(x);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
#ifndef _gcem_tan_HPP
|
||||
#define _gcem_tan_HPP
|
||||
|
||||
#include <cmath>
|
||||
#include <type_traits>
|
||||
|
||||
namespace internal
|
||||
{
|
||||
|
||||
@@ -134,7 +137,11 @@ return_t<T>
|
||||
tan(const T x)
|
||||
noexcept
|
||||
{
|
||||
if (std::is_constant_evaluated()) {
|
||||
return internal::tan_check( static_cast<return_t<T>>(x) );
|
||||
} else {
|
||||
return std::tan(x);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
#ifndef _gcem_tanh_HPP
|
||||
#define _gcem_tanh_HPP
|
||||
|
||||
#include <cmath>
|
||||
#include <type_traits>
|
||||
|
||||
namespace internal
|
||||
{
|
||||
|
||||
@@ -83,7 +86,11 @@ return_t<T>
|
||||
tanh(const T x)
|
||||
noexcept
|
||||
{
|
||||
if (std::is_constant_evaluated()) {
|
||||
return internal::tanh_check( static_cast<return_t<T>>(x) );
|
||||
} else {
|
||||
return std::tanh(x);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
#ifndef _gcem_tgamma_HPP
|
||||
#define _gcem_tgamma_HPP
|
||||
|
||||
#include <cmath>
|
||||
#include <type_traits>
|
||||
|
||||
namespace internal
|
||||
{
|
||||
|
||||
@@ -74,7 +77,11 @@ return_t<T>
|
||||
tgamma(const T x)
|
||||
noexcept
|
||||
{
|
||||
if (std::is_constant_evaluated()) {
|
||||
return internal::tgamma_check( static_cast<return_t<T>>(x) );
|
||||
} else {
|
||||
return std::tgamma(x);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
#ifndef _gcem_trunc_HPP
|
||||
#define _gcem_trunc_HPP
|
||||
|
||||
#include <cmath>
|
||||
#include <type_traits>
|
||||
|
||||
namespace internal
|
||||
{
|
||||
|
||||
@@ -115,7 +118,11 @@ return_t<T>
|
||||
trunc(const T x)
|
||||
noexcept
|
||||
{
|
||||
if (std::is_constant_evaluated()) {
|
||||
return internal::trunc_check( static_cast<return_t<T>>(x) );
|
||||
} else {
|
||||
return std::trunc(x);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user