43 lines · plain
1// (C) Copyright Matt Borland 2021.2// Use, modification and distribution are subject to the3// Boost Software License, Version 1.0. (See accompanying file4// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)5 6#ifndef BOOST_MATH_CCMATH_ISNAN7#define BOOST_MATH_CCMATH_ISNAN8 9#include <boost/math/special_functions/fpclassify.hpp>10#include <boost/math/ccmath/detail/config.hpp>11 12#ifdef BOOST_MATH_NO_CCMATH13#error "The header <boost/math/isnan.hpp> can only be used in C++17 and later."14#endif15 16namespace boost::math::ccmath {17 18template <typename T>19inline constexpr bool isnan BOOST_MATH_PREVENT_MACRO_SUBSTITUTION(T x)20{21 if(BOOST_MATH_IS_CONSTANT_EVALUATED(x))22 {23 return x != x;24 }25 else26 {27 using boost::math::isnan;28 29 if constexpr (!std::is_integral_v<T>)30 {31 return (isnan)(x);32 }33 else34 {35 return (isnan)(static_cast<double>(x));36 }37 }38}39 40}41 42#endif // BOOST_MATH_CCMATH_ISNAN43