File indexing completed on 2025-01-30 09:45:15
0001
0002
0003
0004
0005
0006 #ifndef BOOST_MATH_CCMATH_ISFINITE
0007 #define BOOST_MATH_CCMATH_ISFINITE
0008
0009 #include <boost/math/ccmath/detail/config.hpp>
0010
0011 #ifdef BOOST_MATH_NO_CCMATH
0012 #error "The header <boost/math/isfinite.hpp> can only be used in C++17 and later."
0013 #endif
0014
0015 #include <boost/math/ccmath/isinf.hpp>
0016 #include <boost/math/ccmath/isnan.hpp>
0017
0018 namespace boost::math::ccmath {
0019
0020 template <typename T>
0021 inline constexpr bool isfinite(T x)
0022 {
0023 if(BOOST_MATH_IS_CONSTANT_EVALUATED(x))
0024 {
0025
0026
0027 if constexpr (std::is_integral_v<T>)
0028 {
0029 return !boost::math::ccmath::isinf(static_cast<double>(x)) && !boost::math::ccmath::isnan(static_cast<double>(x));
0030 }
0031 else
0032 {
0033 return !boost::math::ccmath::isinf(x) && !boost::math::ccmath::isnan(x);
0034 }
0035 }
0036 else
0037 {
0038 using std::isfinite;
0039
0040 if constexpr (!std::is_integral_v<T>)
0041 {
0042 return isfinite(x);
0043 }
0044 else
0045 {
0046 return isfinite(static_cast<double>(x));
0047 }
0048 }
0049 }
0050
0051 }
0052
0053 #endif