Skip to content

Commit 7a0ea9b

Browse files
committed
Merge branch 'concepts' of https://github.com/mborland/math into concepts
2 parents cb32691 + 3420530 commit 7a0ea9b

File tree

5 files changed

+559
-130
lines changed

5 files changed

+559
-130
lines changed

include/boost/math/ccmath/abs.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <type_traits>
1313
#include <limits>
1414
#include <boost/math/tools/is_constant_evaluated.hpp>
15+
#include <boost/math/concepts/concepts.hpp>
1516
#include <boost/math/ccmath/isnan.hpp>
1617
#include <boost/math/ccmath/isinf.hpp>
1718

@@ -27,7 +28,7 @@ namespace boost::math::ccmath {
2728

2829
namespace detail {
2930

30-
template <typename T>
31+
template <BOOST_MATH_ARBITRARY_SIGNED_ARITHMETIC T>
3132
inline constexpr T abs_impl(T x) noexcept
3233
{
3334
return boost::math::ccmath::isnan(x) ? std::numeric_limits<T>::quiet_NaN() :
@@ -40,6 +41,7 @@ inline constexpr T abs_impl(T x) noexcept
4041
} // Namespace detail
4142

4243
template <typename T, std::enable_if_t<!std::is_unsigned_v<T>, bool> = true>
44+
BOOST_MATH_REQUIRES(BOOST_MATH_ARBITRARY_SIGNED_ARITHMETIC, T)
4345
inline constexpr T abs(T x) noexcept
4446
{
4547
if(BOOST_MATH_IS_CONSTANT_EVALUATED(x))
@@ -56,6 +58,7 @@ inline constexpr T abs(T x) noexcept
5658
// If abs() is called with an argument of type X for which is_unsigned_v<X> is true and if X
5759
// cannot be converted to int by integral promotion (7.3.7), the program is ill-formed.
5860
template <typename T, std::enable_if_t<std::is_unsigned_v<T>, bool> = true>
61+
BOOST_MATH_REQUIRES(BOOST_MATH_ARBITRARY_UNSIGNED_ARITHMETIC, T)
5962
inline constexpr T abs(T x) noexcept
6063
{
6164
if constexpr (std::is_convertible_v<T, int>)

0 commit comments

Comments
 (0)