12
12
#include < type_traits>
13
13
#include < limits>
14
14
#include < boost/math/tools/is_constant_evaluated.hpp>
15
+ #include < boost/math/concepts/concepts.hpp>
15
16
#include < boost/math/ccmath/isnan.hpp>
16
17
#include < boost/math/ccmath/isinf.hpp>
17
18
@@ -27,7 +28,7 @@ namespace boost::math::ccmath {
27
28
28
29
namespace detail {
29
30
30
- template <typename T>
31
+ template <BOOST_MATH_ARBITRARY_SIGNED_ARITHMETIC T>
31
32
inline constexpr T abs_impl (T x) noexcept
32
33
{
33
34
return boost::math::ccmath::isnan (x) ? std::numeric_limits<T>::quiet_NaN () :
@@ -40,6 +41,7 @@ inline constexpr T abs_impl(T x) noexcept
40
41
} // Namespace detail
41
42
42
43
template <typename T, std::enable_if_t <!std::is_unsigned_v<T>, bool > = true >
44
+ BOOST_MATH_REQUIRES (BOOST_MATH_ARBITRARY_SIGNED_ARITHMETIC, T)
43
45
inline constexpr T abs (T x) noexcept
44
46
{
45
47
if (BOOST_MATH_IS_CONSTANT_EVALUATED (x))
@@ -56,6 +58,7 @@ inline constexpr T abs(T x) noexcept
56
58
// If abs() is called with an argument of type X for which is_unsigned_v<X> is true and if X
57
59
// cannot be converted to int by integral promotion (7.3.7), the program is ill-formed.
58
60
template <typename T, std::enable_if_t <std::is_unsigned_v<T>, bool > = true >
61
+ BOOST_MATH_REQUIRES (BOOST_MATH_ARBITRARY_UNSIGNED_ARITHMETIC, T)
59
62
inline constexpr T abs (T x) noexcept
60
63
{
61
64
if constexpr (std::is_convertible_v<T, int >)
0 commit comments