Skip to content

Commit

Permalink
STYLE: Use default member initialization
Browse files Browse the repository at this point in the history
Converts a default constructor’s member initializers into the new
default member initializers in C++11. Other member initializers that match the
default member initializer are removed. This can reduce repeated code or allow
use of ‘= default’.
  • Loading branch information
hjmjohnson committed Dec 11, 2024
1 parent ddc8c11 commit 4327c3c
Show file tree
Hide file tree
Showing 17 changed files with 22 additions and 36 deletions.
3 changes: 1 addition & 2 deletions Modules/Core/Common/include/itkConstSliceIterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ class ConstSliceIterator
/** Constructor. */
ConstSliceIterator(const TContainer * n, std::slice s)
: m_ContainerPointer(n)
, m_Pos(0)
, m_Slice(s)
{}

Expand Down Expand Up @@ -146,7 +145,7 @@ class ConstSliceIterator
const TContainer * m_ContainerPointer;

/** Current position within the slice. */
SizeValueType m_Pos;
SizeValueType m_Pos{ 0 };

/** Slice structure information. */
std::slice m_Slice;
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkProgressReporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class ITKCommon_EXPORT ProgressReporter
ProcessObject * m_Filter;
ThreadIdType m_ThreadId;
float m_InverseNumberOfPixels;
SizeValueType m_CurrentPixel;
SizeValueType m_CurrentPixel{ 0 };
SizeValueType m_PixelsPerUpdate;
SizeValueType m_PixelsBeforeUpdate;
float m_InitialProgress;
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkProgressTransformer.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class ITKCommon_EXPORT ProgressTransformer
using CommandType = SimpleMemberCommand<ProgressTransformer>;
CommandType::Pointer m_ProgressCommand;

unsigned long m_ProgressTag;
unsigned long m_ProgressTag{ 0 };
};
} // end namespace itk
#endif // itkProgressTransformer_h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ ShapedFloodFilledFunctionConditionalConstIterator<TImage, TFunction>::ShapedFloo
const ImageType * imagePtr,
FunctionType * fnPtr,
IndexType startIndex)
: m_FullyConnected(false)

{
this->m_Image = imagePtr;
m_Function = fnPtr;
Expand All @@ -43,7 +43,7 @@ ShapedFloodFilledFunctionConditionalConstIterator<TImage, TFunction>::ShapedFloo
FunctionType * fnPtr,
std::vector<IndexType> & startIndex)
: m_Function(fnPtr)
, m_FullyConnected(false)

{
this->m_Image = imagePtr; // can not be done in the initialization list

Expand All @@ -61,7 +61,7 @@ template <typename TImage, typename TFunction>
ShapedFloodFilledFunctionConditionalConstIterator<TImage, TFunction>::ShapedFloodFilledFunctionConditionalConstIterator(
const ImageType * imagePtr,
FunctionType * fnPtr)
: m_FullyConnected(false)

{
this->m_Image = imagePtr;
m_Function = fnPtr;
Expand Down
3 changes: 1 addition & 2 deletions Modules/Core/Common/include/itkSliceIterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ class SliceIterator
/** Constructor. */
SliceIterator(TContainer * n, std::slice s)
: m_ContainerPointer(n)
, m_Pos(0)
, m_Slice(s)
{}

Expand Down Expand Up @@ -145,7 +144,7 @@ class SliceIterator
TContainer * m_ContainerPointer;

/** Current position within the slice. */
OffsetValueType m_Pos;
OffsetValueType m_Pos{ 0 };

/** Slice structure information. */
std::slice m_Slice;
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkTotalProgressReporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class ITKCommon_EXPORT TotalProgressReporter
protected:
ProcessObject * m_Filter;
float m_InverseNumberOfPixels;
SizeValueType m_CurrentPixel;
SizeValueType m_CurrentPixel{ 0 };
SizeValueType m_PixelsPerUpdate;
SizeValueType m_PixelsBeforeUpdate;
float m_ProgressWeight;
Expand Down
1 change: 0 additions & 1 deletion Modules/Core/Common/src/itkProgressReporter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ ProgressReporter::ProgressReporter(ProcessObject * filter,
float progressWeight)
: m_Filter(filter)
, m_ThreadId(threadId)
, m_CurrentPixel(0)
, m_InitialProgress(initialProgress)
, m_ProgressWeight(progressWeight)
{
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/src/itkProgressTransformer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class DummyProcess : public itk::ProcessObject

ProgressTransformer::ProgressTransformer(float start, float end, ProcessObject * targetFilter)
: m_TargetFilter(targetFilter)
, m_ProgressTag(0)

{
m_Start = std::clamp(start, 0.0f, 1.0f);
m_End = std::clamp(end, 0.0f, 1.0f);
Expand Down
1 change: 0 additions & 1 deletion Modules/Core/Common/src/itkTotalProgressReporter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ TotalProgressReporter::TotalProgressReporter(ProcessObject * filter,
SizeValueType numberOfUpdates,
float progressWeight)
: m_Filter(filter)
, m_CurrentPixel(0)
, m_ProgressWeight(progressWeight)
{
// Make sure we have at least one pixel.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ namespace itk
{
template <typename TInputImage, typename TCoordinate>
MahalanobisDistanceThresholdImageFunction<TInputImage, TCoordinate>::MahalanobisDistanceThresholdImageFunction()
: m_Threshold(0.0)
, m_MahalanobisDistanceMembershipFunction(MahalanobisDistanceFunctionType::New())
: m_MahalanobisDistanceMembershipFunction(MahalanobisDistanceFunctionType::New())
{}

template <typename TInputImage, typename TCoordinate>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class ScanlineFilterCommon

ScanlineFilterCommon(EnclosingFilter * enclosingFilter)
: m_EnclosingFilter(enclosingFilter)
, m_FullyConnected(false)

{}
~ScanlineFilterCommon() = default;

Expand Down Expand Up @@ -505,7 +505,7 @@ class ScanlineFilterCommon
}

protected:
bool m_FullyConnected;
bool m_FullyConnected{ false };
OffsetVectorType m_LineOffsets;
UnionFindType m_UnionFind;
ConsecutiveVectorType m_Consecutive;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ template <typename TInputPixel, typename TOutputPixel>
class BinaryAccumulator
{
public:
BinaryAccumulator(unsigned long)
: m_IsForeground(false)
{}
BinaryAccumulator(unsigned long) {}
~BinaryAccumulator() = default;

inline void
Expand Down Expand Up @@ -68,7 +66,7 @@ class BinaryAccumulator
}
}

bool m_IsForeground;
bool m_IsForeground{ false };
};
} // end namespace Function

Expand Down
8 changes: 2 additions & 6 deletions Modules/IO/JPEG/src/itkJPEGImageIO.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,7 @@ namespace itk
class JPEGFileWrapper
{
public:
JPEGFileWrapper(const char * const fname, const char * const openMode)
: m_FilePointer(nullptr)
{
m_FilePointer = fopen(fname, openMode);
}
JPEGFileWrapper(const char * const fname, const char * const openMode) { m_FilePointer = fopen(fname, openMode); }

virtual ~JPEGFileWrapper()
{
Expand All @@ -84,7 +80,7 @@ class JPEGFileWrapper
}
}

FILE * volatile m_FilePointer;
FILE * volatile m_FilePointer{ nullptr };
};

bool
Expand Down
1 change: 1 addition & 0 deletions Modules/IO/NIFTI/src/itkNiftiImageIO.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ class NiftiImageIO::NiftiImageProxy
NiftiImageIO::NiftiImageIO()
: m_NiftiImageHolder(new NiftiImageProxy(nullptr))
, m_NiftiImage(*m_NiftiImageHolder.get())
// initialization of m_LegacyAnalyze75Mode & m_SFORM_Permissive in cxx so itkNiftiImageIOConfigurePrivate.h is private
, m_LegacyAnalyze75Mode{ ITK_NIFTI_IO_ANALYZE_FLAVOR_DEFAULT }
, m_SFORM_Permissive{ ITK_NIFTI_IO_SFORM_PERMISSIVE_DEFAULT }
{
Expand Down
8 changes: 2 additions & 6 deletions Modules/IO/PNG/src/itkPNGImageIO.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,7 @@ namespace itk
class PNGFileWrapper
{
public:
PNGFileWrapper(const char * const fname, const char * const openMode)
: m_FilePointer(nullptr)
{
m_FilePointer = fopen(fname, openMode);
}
PNGFileWrapper(const char * const fname, const char * const openMode) { m_FilePointer = fopen(fname, openMode); }

virtual ~PNGFileWrapper()
{
Expand All @@ -57,7 +53,7 @@ class PNGFileWrapper
}
}

FILE * volatile m_FilePointer;
FILE * volatile m_FilePointer{ nullptr };
};

bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ class ITKPolynomials_EXPORT MultivariateLegendrePolynomial
: m_MultivariateLegendrePolynomial(polynomial)
, m_Dimension(m_MultivariateLegendrePolynomial->GetDimension())
, m_DomainSize(m_MultivariateLegendrePolynomial->GetDomainSize())
, m_IsAtEnd(false)

{
m_Index.resize(m_Dimension);
std::fill(m_Index.begin(), m_Index.end(), 0);
Expand Down Expand Up @@ -284,7 +284,7 @@ class ITKPolynomials_EXPORT MultivariateLegendrePolynomial
unsigned int m_Dimension;
DomainSizeType m_DomainSize;
IndexType m_Index;
bool m_IsAtEnd;
bool m_IsAtEnd{ false };
}; // end of class Iterator

void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class SimpleMultiResolutionImageRegistrationUI
{
public:
SimpleMultiResolutionImageRegistrationUI(TRegistrator * ptr)
: m_Tag(0)

{

if (!ptr)
Expand Down

0 comments on commit 4327c3c

Please # to comment.