Skip to content

Commit

Permalink
STYLE: Use MakeFilled in any fixed array NumericTraits specialization
Browse files Browse the repository at this point in the history
Uses MakeFilled in the `NumericTraits` specializations of "fixed array"
classes: CovariantVector, DiffusionTensor3D, FixedArray, and
SymmetricSecondRankTensor.

Follow-up to:
pull request #3262
commit 82001f3
"STYLE: Use MakeFilled, () or {}, instead of `Vector(const ValueType &)`"
  • Loading branch information
N-Dekker authored and hjmjohnson committed Mar 12, 2022
1 parent fa58a4d commit 908a29a
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,43 +86,43 @@ class NumericTraits<CovariantVector<T, D>>
static const Self
max(const Self &)
{
return Self(NumericTraits<T>::max());
return MakeFilled<Self>(NumericTraits<T>::max());
}

static const Self
min(const Self &)
{
return Self(NumericTraits<T>::min());
return MakeFilled<Self>(NumericTraits<T>::min());
}

static const Self
max()
{
return Self(NumericTraits<T>::max());
return MakeFilled<Self>(NumericTraits<T>::max());
}

static const Self
min()
{
return Self(NumericTraits<T>::min());
return MakeFilled<Self>(NumericTraits<T>::min());
}

static const Self
NonpositiveMin()
{
return Self(NumericTraits<T>::NonpositiveMin());
return MakeFilled<Self>(NumericTraits<T>::NonpositiveMin());
}

static const Self
ZeroValue()
{
return Self(NumericTraits<T>::ZeroValue());
return MakeFilled<Self>(NumericTraits<T>::ZeroValue());
}

static const Self
OneValue()
{
return Self(NumericTraits<T>::OneValue());
return MakeFilled<Self>(NumericTraits<T>::OneValue());
}

static const Self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,61 +87,61 @@ class NumericTraits<DiffusionTensor3D<T>>
static const Self
max(const Self &)
{
return Self(NumericTraits<T>::max());
return MakeFilled<Self>(NumericTraits<T>::max());
}

static const Self
min(const Self &)
{
return Self(NumericTraits<T>::min());
return MakeFilled<Self>(NumericTraits<T>::min());
}

static const Self
NonpositiveMin(const Self &)
max()
{
return Self(NumericTraits<T>::NonpositiveMin());
return MakeFilled<Self>(NumericTraits<T>::max());
}

static const Self
ZeroValue(const Self &)
min()
{
return Self(NumericTraits<T>::ZeroValue());
return MakeFilled<Self>(NumericTraits<T>::min());
}

static const Self
OneValue(const Self &)
NonpositiveMin()
{
return Self(NumericTraits<T>::OneValue());
return MakeFilled<Self>(NumericTraits<T>::NonpositiveMin());
}

static const Self
max()
ZeroValue()
{
return Self(NumericTraits<T>::max());
return MakeFilled<Self>(NumericTraits<T>::ZeroValue());
}

static const Self
min()
OneValue()
{
return Self(NumericTraits<T>::min());
return MakeFilled<Self>(NumericTraits<T>::OneValue());
}

static const Self
NonpositiveMin()
NonpositiveMin(const Self &)
{
return Self(NumericTraits<T>::NonpositiveMin());
return NonpositiveMin();
}

static const Self
ZeroValue()
ZeroValue(const Self &)
{
return Self(NumericTraits<T>::ZeroValue());
return ZeroValue();
}

static const Self
OneValue()
OneValue(const Self &)
{
return Self(NumericTraits<T>::OneValue());
return OneValue();
}

static constexpr bool IsSigned = std::is_signed<ValueType>::value;
Expand Down
14 changes: 7 additions & 7 deletions Modules/Core/Common/include/itkNumericTraitsFixedArrayPixel.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,43 +86,43 @@ class NumericTraits<FixedArray<T, D>>
static const Self
max(const Self &)
{
return Self(NumericTraits<T>::max());
return MakeFilled<Self>(NumericTraits<T>::max());
}

static const Self
min(const Self &)
{
return Self(NumericTraits<T>::min());
return MakeFilled<Self>(NumericTraits<T>::min());
}

static const Self
max()
{
return Self(NumericTraits<T>::max());
return MakeFilled<Self>(NumericTraits<T>::max());
}

static const Self
min()
{
return Self(NumericTraits<T>::min());
return MakeFilled<Self>(NumericTraits<T>::min());
}

static const Self
NonpositiveMin()
{
return Self(NumericTraits<T>::NonpositiveMin());
return MakeFilled<Self>(NumericTraits<T>::NonpositiveMin());
}

static const Self
ZeroValue()
{
return Self(NumericTraits<T>::ZeroValue());
return MakeFilled<Self>(NumericTraits<T>::ZeroValue());
}

static const Self
OneValue()
{
return Self(NumericTraits<T>::OneValue());
return MakeFilled<Self>(NumericTraits<T>::OneValue());
}

static const Self
Expand Down
14 changes: 7 additions & 7 deletions Modules/Core/Common/include/itkNumericTraitsTensorPixel.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,43 +86,43 @@ class NumericTraits<SymmetricSecondRankTensor<T, D>>
static const Self
max(const Self &)
{
return Self(NumericTraits<T>::max());
return MakeFilled<Self>(NumericTraits<T>::max());
}

static const Self
min(const Self &)
{
return Self(NumericTraits<T>::min());
return MakeFilled<Self>(NumericTraits<T>::min());
}

static const Self
max()
{
return Self(NumericTraits<T>::max());
return MakeFilled<Self>(NumericTraits<T>::max());
}

static const Self
min()
{
return Self(NumericTraits<T>::min());
return MakeFilled<Self>(NumericTraits<T>::min());
}

static const Self
NonpositiveMin()
{
return Self(NumericTraits<T>::NonpositiveMin());
return MakeFilled<Self>(NumericTraits<T>::NonpositiveMin());
}

static const Self
ZeroValue()
{
return Self(NumericTraits<T>::ZeroValue());
return MakeFilled<Self>(NumericTraits<T>::ZeroValue());
}

static const Self
OneValue()
{
return Self(NumericTraits<T>::OneValue());
return MakeFilled<Self>(NumericTraits<T>::OneValue());
}

static const Self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@ namespace itk
// NumericTraits<>.
//

#define DIFFUSIONTENSOR3DPIXELSTATICTRAITSMACRO(T) \
template <> \
ITKCommon_EXPORT const DiffusionTensor3D<T> NumericTraits<DiffusionTensor3D<T>>::Zero = \
DiffusionTensor3D<T>(NumericTraits<T>::Zero); \
template <> \
ITKCommon_EXPORT const DiffusionTensor3D<T> NumericTraits<DiffusionTensor3D<T>>::One = \
DiffusionTensor3D<T>(NumericTraits<T>::One);
#define DIFFUSIONTENSOR3DPIXELSTATICTRAITSMACRO(T) \
template <> \
ITKCommon_EXPORT const DiffusionTensor3D<T> NumericTraits<DiffusionTensor3D<T>>::Zero{}; \
template <> \
ITKCommon_EXPORT const DiffusionTensor3D<T> NumericTraits<DiffusionTensor3D<T>>::One = \
MakeFilled<DiffusionTensor3D<T>>(1);

//
// List here the specializations of the Traits:
Expand Down

0 comments on commit 908a29a

Please sign in to comment.