Debian Codegraph @

third-party/boost-math/include/boost/math/ccmath/isnan.hpp

raw
1 // (C) Copyright Matt Borland 2021.
2 // Use, modification and distribution are subject to the
3 // Boost Software License, Version 1.0. (See accompanying file
4 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6 #ifndef BOOST_MATH_CCMATH_ISNAN
7 #define BOOST_MATH_CCMATH_ISNAN
8
9 #include <boost/math/special_functions/fpclassify.hpp>
10 #include <boost/math/ccmath/detail/config.hpp>
11
12 #ifdef BOOST_MATH_NO_CCMATH
13 #error "The header <boost/math/isnan.hpp> can only be used in C++17 and later."
14 #endif
15
16 namespace boost::math::ccmath {
17
18 template <typename T>
19 inline 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 else
26 {
27 using boost::math::isnan;
28
29 if constexpr (!std::is_integral_v<T>)
30 {
31 return (isnan)(x);
32 }
33 else
34 {
35 return (isnan)(static_cast<double>(x));
36 }
37 }
38 }
39
40 }
41
42 #endif // BOOST_MATH_CCMATH_ISNAN