Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:39:32

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_ISINF
0007 #define BOOST_MATH_CCMATH_ISINF
0008 
0009 #include <boost/math/special_functions/fpclassify.hpp>
0010 #include <boost/math/ccmath/detail/config.hpp>
0011 
0012 #ifdef BOOST_MATH_NO_CCMATH
0013 #error "The header <boost/math/isinf.hpp> can only be used in C++17 and later."
0014 #endif
0015 
0016 namespace boost::math::ccmath {
0017 
0018 template <typename T>
0019 constexpr bool isinf BOOST_PREVENT_MACRO_SUBSTITUTION(T x) noexcept
0020 {
0021     if(BOOST_MATH_IS_CONSTANT_EVALUATED(x))
0022     {
0023         if constexpr (std::numeric_limits<T>::is_signed)
0024         {
0025             return x == std::numeric_limits<T>::infinity() || -x == std::numeric_limits<T>::infinity();
0026         }
0027         else
0028         {
0029             return x == std::numeric_limits<T>::infinity();
0030         }
0031     }
0032     else
0033     {
0034         using boost::math::isinf;
0035         
0036         if constexpr (!std::is_integral_v<T>)
0037         {
0038             return (isinf)(x);
0039         }
0040         else
0041         {
0042             return (isinf)(static_cast<double>(x));
0043         }
0044     }
0045 }
0046 
0047 }
0048 
0049 #endif // BOOST_MATH_CCMATH_ISINF