File indexing completed on 2025-09-17 08:35:16
0001
0002
0003
0004
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_MATH_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 #if defined(__clang_major__) && __clang_major__ >= 6
0026 # pragma clang diagnostic push
0027 # pragma clang diagnostic ignored "-Wtautological-constant-compare"
0028 # if defined(__has_warning)
0029 # if __has_warning("-Wnan-infinity-disabled")
0030 # pragma clang diagnostic ignored "-Wnan-infinity-disabled"
0031 # endif
0032 # endif
0033 #endif
0034 return x == std::numeric_limits<T>::infinity() || -x == std::numeric_limits<T>::infinity();
0035 #if defined(__clang_major__) && __clang_major__ >= 6
0036 #pragma clang diagnostic pop
0037 #endif
0038 }
0039 else
0040 {
0041 return x == std::numeric_limits<T>::infinity();
0042 }
0043 }
0044 else
0045 {
0046 using boost::math::isinf;
0047
0048 if constexpr (!std::is_integral_v<T>)
0049 {
0050 return (isinf)(x);
0051 }
0052 else
0053 {
0054 return (isinf)(static_cast<double>(x));
0055 }
0056 }
0057 }
0058
0059 }
0060
0061 #endif