Make specialization for all unsigned integer types.
This commit is contained in:
parent
291b13c2d4
commit
89cb2680a1
@ -579,25 +579,26 @@ private:
|
|||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
/// \brief Computes the maximum of the absolute values of two values.
|
/// \brief Computes the maximum of the absolute values of two values.
|
||||||
template<typename T>
|
template<typename T, typename Enable = void>
|
||||||
struct MaxAbsFunctor
|
struct MaxAbsFunctor
|
||||||
{
|
{
|
||||||
typedef T result_type;
|
using result_type = T;
|
||||||
|
result_type operator()(const T& t1,
|
||||||
result_type operator()(const T& t1, const T& t2)
|
const T& t2)
|
||||||
{
|
{
|
||||||
return std::max(std::abs(t1),std::abs(t2));
|
return std::max(std::abs(t1), std::abs(t2));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Specialization for unsigned integers. They need their own
|
||||||
/// \brief Specialization to avoid ambiguous abs() for unsigned integers.
|
// version since abs(x) is ambiguous (as well as somewhat
|
||||||
template <>
|
// meaningless).
|
||||||
struct MaxAbsFunctor<std::size_t>
|
template<typename T>
|
||||||
|
struct MaxAbsFunctor<T, typename std::enable_if<std::is_unsigned<T>::value>::type>
|
||||||
{
|
{
|
||||||
typedef std::size_t result_type;
|
using result_type = T;
|
||||||
|
result_type operator()(const T& t1,
|
||||||
result_type operator()(const std::size_t& t1, const std::size_t& t2)
|
const T& t2)
|
||||||
{
|
{
|
||||||
return std::max(t1, t2);
|
return std::max(t1, t2);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user