1#ifndef CONSTMATH_UTILITIES_HPP
2#define CONSTMATH_UTILITIES_HPP
13template <
typename T>
struct is_float_impl
15 static constexpr bool _()
21template <>
struct is_float_impl<
float>
23 static constexpr bool _()
29template <>
struct is_float_impl<
double>
31 static constexpr bool _()
39 static constexpr bool _()
47template <
typename T>
constexpr bool is_float(
T const &)
49 return is_float_impl<T>::_();
65 return is_float_impl<T>::_();
86 return static_cast<T>(0);
92 if (
sizeof(
T) ==
sizeof(
float))
94 return static_cast<T>(1.19209290e-7);
96 if (
sizeof(
T) ==
sizeof(
double))
98 return static_cast<T>(2.2204460492503131e-16);
102 T eps =
static_cast<T>(1.0);
103 T one =
static_cast<T>(1.0);
104 T half =
static_cast<T>(0.5);
126template <
typename T>
T force_compile_time_error_for_negative_sqrt()
130 return static_cast<T>(0.0) /
static_cast<T>(0.0);
134 return static_cast<T>(-1);
139template <
typename T>
constexpr T poison_nan()
148template <
typename T>
constexpr bool is_poison_nan(
const T x)
157 return x ==
static_cast<T>(-1);
constexpr bool is_float()
Returns true if T is a floating-point type (type-only overload).
Definition utilities.hpp:63
constexpr T epsilon()
Machine epsilon for type T.
Definition utilities.hpp:82