Skip to content

Commit

Permalink
STYLE: Remove IsSigned and replace with std::is_signed
Browse files Browse the repository at this point in the history
Prefer builtin C++11 language features for identifying
signed types.

:%s#NumericTraits<\([^>]*\)>::IsSigned#std::is_signed<\1>::value#gc
  • Loading branch information
hjmjohnson authored and N-Dekker committed Nov 14, 2021
1 parent b3f80bb commit da13473
Show file tree
Hide file tree
Showing 13 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions Modules/Core/Common/include/itkMath.h
Original file line number Diff line number Diff line change
Expand Up @@ -516,9 +516,9 @@ template <typename TInputType1, typename TInputType2>
struct AlmostEqualsScalarImplementer
{
static constexpr bool TInputType1IsInteger = std::is_integral<TInputType1>::value;
static constexpr bool TInputType1IsSigned = itk::NumericTraits<TInputType1>::IsSigned;
static constexpr bool TInputType1IsSigned = std::is_signed<TInputType1>::value;
static constexpr bool TInputType2IsInteger = std::is_integral<TInputType2>::value;
static constexpr bool TInputType2IsSigned = itk::NumericTraits<TInputType2>::IsSigned;
static constexpr bool TInputType2IsSigned = std::is_signed<TInputType2>::value;

using SelectedVersion = typename AlmostEqualsFunctionSelector<TInputType1IsInteger,
TInputType1IsSigned,
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkNumericTraits.h
Original file line number Diff line number Diff line change
Expand Up @@ -1924,7 +1924,7 @@ class NumericTraits<std::complex<TComponent>>
return val.real() >= 0;
}

static constexpr bool IsSigned = NumericTraits<ValueType>::IsSigned;
static constexpr bool IsSigned = std::is_signed<ValueType>::value;
static constexpr bool IsInteger = false;
static constexpr bool IsComplex = true;
static Self
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkNumericTraitsArrayPixel.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class NumericTraits<Array<T>>
return b;
}

static constexpr bool IsSigned = NumericTraits<ValueType>::IsSigned;
static constexpr bool IsSigned = std::is_signed<ValueType>::value;
static constexpr bool IsInteger = std::is_integral<ValueType>::value;
static constexpr bool IsComplex = NumericTraits<ValueType>::IsComplex;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class NumericTraits<CovariantVector<T, D>>
return OneValue();
}

static constexpr bool IsSigned = NumericTraits<ValueType>::IsSigned;
static constexpr bool IsSigned = std::is_signed<ValueType>::value;
static constexpr bool IsInteger = std::is_integral<ValueType>::value;
static constexpr bool IsComplex = NumericTraits<ValueType>::IsComplex;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class NumericTraits<DiffusionTensor3D<T>>
return Self(NumericTraits<T>::OneValue());
}

static constexpr bool IsSigned = NumericTraits<ValueType>::IsSigned;
static constexpr bool IsSigned = std::is_signed<ValueType>::value;
static constexpr bool IsInteger = std::is_integral<ValueType>::value;
static constexpr bool IsComplex = NumericTraits<ValueType>::IsComplex;

Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkNumericTraitsPointPixel.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class NumericTraits<Point<T, D>>
return OneValue();
}

static constexpr bool IsSigned = NumericTraits<ValueType>::IsSigned;
static constexpr bool IsSigned = std::is_signed<ValueType>::value;
static constexpr bool IsInteger = std::is_integral<ValueType>::value;
static constexpr bool IsComplex = NumericTraits<ValueType>::IsComplex;

Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkNumericTraitsRGBAPixel.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class NumericTraits<RGBAPixel<T>>
return NumericTraits<typename Self::LuminanceType>::IsNonnegative(val.GetLuminance());
}

static constexpr bool IsSigned = NumericTraits<ValueType>::IsSigned;
static constexpr bool IsSigned = std::is_signed<ValueType>::value;
static constexpr bool IsInteger = std::is_integral<ValueType>::value;
static constexpr bool IsComplex = NumericTraits<ValueType>::IsComplex;

Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkNumericTraitsRGBPixel.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class NumericTraits<RGBPixel<T>>
return NumericTraits<typename Self::LuminanceType>::IsNonnegative(val.GetLuminance());
}

static constexpr bool IsSigned = NumericTraits<ValueType>::IsSigned;
static constexpr bool IsSigned = std::is_signed<ValueType>::value;
static constexpr bool IsInteger = std::is_integral<ValueType>::value;
static constexpr bool IsComplex = NumericTraits<ValueType>::IsComplex;

Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkNumericTraitsStdVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class NumericTraits<std::vector<T>>
return b;
}

static constexpr bool IsSigned = NumericTraits<ValueType>::IsSigned;
static constexpr bool IsSigned = std::is_signed<ValueType>::value;
static constexpr bool IsInteger = std::is_integral<ValueType>::value;
static constexpr bool IsComplex = NumericTraits<ValueType>::IsComplex;

Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkNumericTraitsTensorPixel.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class NumericTraits<SymmetricSecondRankTensor<T, D>>
return OneValue();
}

static constexpr bool IsSigned = NumericTraits<ValueType>::IsSigned;
static constexpr bool IsSigned = std::is_signed<ValueType>::value;
static constexpr bool IsInteger = std::is_integral<ValueType>::value;
static constexpr bool IsComplex = NumericTraits<ValueType>::IsComplex;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class NumericTraits<VariableLengthVector<T>>
return flag;
}

static constexpr bool IsSigned = NumericTraits<ValueType>::IsSigned;
static constexpr bool IsSigned = std::is_signed<ValueType>::value;
static constexpr bool IsInteger = std::is_integral<ValueType>::value;
static constexpr bool IsComplex = NumericTraits<ValueType>::IsComplex;

Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkNumericTraitsVectorPixel.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class NumericTraits<Vector<T, D>>
return flag;
}

static constexpr bool IsSigned = NumericTraits<ValueType>::IsSigned;
static constexpr bool IsSigned = std::is_signed<ValueType>::value;
static constexpr bool IsInteger = std::is_integral<ValueType>::value;
static constexpr bool IsComplex = NumericTraits<ValueType>::IsComplex;

Expand Down
8 changes: 4 additions & 4 deletions Modules/Core/Common/test/itkNumericTraitsTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -210,17 +210,17 @@ CheckSignedAndIntegerTraitsSameAsSTDNumericLimits(const char * const name)
std::cout << "\tERROR: IsSigned definitions for itk::NumericTraits and std::numeric_limits do not match!! ERROR!!"
<< std::endl;
std::cout << "\tFor type: \t" << name << std::endl;
std::cout << "\tITK signed Value for:\t< " << name << " >\tis:\t"
<< (itk::NumericTraits<T>::IsSigned ? "true" : "false") << std::endl;
std::cout << "\tITK signed Value for:\t< " << name << " >\tis:\t" << (std::is_signed<T>::value ? "true" : "false")
<< std::endl;
std::cout << "\tstd signed Value for:\t< " << name << " >\tis:\t"
<< (std::numeric_limits<T>::is_signed ? "true" : "false") << std::endl;
didTestPass = false;
}
else
{
std::cout << "\tSUCCESS: IsSigned definition for itk::NumericTraits matches std::numeric_limits" << std::endl;
std::cout << "\tSigned Value for:\t< " << name << " >\tis:\t"
<< (itk::NumericTraits<T>::IsSigned ? "true" : "false") << std::endl;
std::cout << "\tSigned Value for:\t< " << name << " >\tis:\t" << (std::is_signed<T>::value ? "true" : "false")
<< std::endl;
}

// test for IsInteger
Expand Down

0 comments on commit da13473

Please sign in to comment.