]>
Commit | Line | Data |
---|---|---|
1e59de90 TL |
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_ISINF | |
7 | #define BOOST_MATH_CCMATH_ISINF | |
8 | ||
9 | #include <cmath> | |
10 | #include <limits> | |
11 | #include <type_traits> | |
12 | #include <boost/math/tools/is_constant_evaluated.hpp> | |
13 | ||
14 | namespace boost::math::ccmath { | |
15 | ||
16 | template <typename T> | |
17 | inline constexpr bool isinf(T x) | |
18 | { | |
19 | if(BOOST_MATH_IS_CONSTANT_EVALUATED(x)) | |
20 | { | |
21 | return x == std::numeric_limits<T>::infinity() || -x == std::numeric_limits<T>::infinity(); | |
22 | } | |
23 | else | |
24 | { | |
25 | using std::isinf; | |
26 | ||
27 | if constexpr (!std::is_integral_v<T>) | |
28 | { | |
29 | return isinf(x); | |
30 | } | |
31 | else | |
32 | { | |
33 | return isinf(static_cast<double>(x)); | |
34 | } | |
35 | } | |
36 | } | |
37 | ||
38 | } | |
39 | ||
40 | #endif // BOOST_MATH_CCMATH_ISINF |