Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:45:15

0001 //  (C) Copyright Matt Borland 2021.
0002 //  Use, modification and distribution are subject to the
0003 //  Boost Software License, Version 1.0. (See accompanying file
0004 //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
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         // bool isfinite (IntegralType arg) is a set of overloads accepting the arg argument of any integral type
0026         // equivalent to casting the integral argument arg to double (e.g. static_cast<double>(arg))
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 // BOOST_MATH_CCMATH_ISFINITE