Skip to content

Commit

Permalink
STYLE: Pefer = default to explicitly trivial implementations
Browse files Browse the repository at this point in the history
This check replaces default bodies of special member functions with
= default;. The explicitly defaulted function declarations enable more
opportunities in optimization, because the compiler might treat
explicitly defaulted functions as trivial.

Additionally, the C++11 use of = default more clearly expreses the
intent for the special member functions.

SRCDIR=/Users/johnsonhj/src/BT-11/ANTs #My local SRC
BLDDIR=/Users/johnsonhj/src/BT-11/ANTs-build #My local BLD

cd /Users/johnsonhj/src/BT-11/ANTs-build
run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,modernize-use-equals-default  -header-filter=.* -fix

STYLE: Pefer = delete to explicitly trivial implementations

This check replaces undefined special member functions with
= delete;. The explicitly deleted function declarations enable more
opportunities in optimization, because the compiler might treat
explicitly delted functions as noops.

Additionally, the C++11 use of = delete more clearly expreses the
intent for the special member functions.

SRCDIR=${SRCDIR} #My local SRC
BLDDIR=${BLDDIR} #My local BLD

cd ${BLDDIR}
run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,modernize-use-equals-delete  -header-filter=.* -fix
  • Loading branch information
hjmjohnson committed Nov 8, 2018
1 parent 83768b4 commit 0836fb4
Show file tree
Hide file tree
Showing 99 changed files with 203 additions and 338 deletions.
4 changes: 1 addition & 3 deletions Examples/Atropos.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ class CommandIterationUpdate : public itk::Command
typedef itk::SmartPointer<Self> Pointer;
itkNewMacro( Self );
protected:
CommandIterationUpdate()
{
};
CommandIterationUpdate() = default;
public:

void Execute(itk::Object *caller, const itk::EventObject & event) override
Expand Down
4 changes: 1 addition & 3 deletions Examples/KellyKapowski.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ class CommandIterationUpdate : public itk::Command
typedef itk::SmartPointer<Self> Pointer;
itkNewMacro( Self );
protected:
CommandIterationUpdate()
{
};
CommandIterationUpdate() = default;
public:

void Execute(itk::Object *caller, const itk::EventObject & event) override
Expand Down
4 changes: 1 addition & 3 deletions Examples/N3BiasFieldCorrection.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ class CommandIterationUpdate : public itk::Command
typedef itk::SmartPointer<Self> Pointer;
itkNewMacro( Self );
protected:
CommandIterationUpdate()
{
};
CommandIterationUpdate() = default;
public:

void Execute(itk::Object *caller, const itk::EventObject & event) override
Expand Down
4 changes: 1 addition & 3 deletions Examples/N4BiasFieldCorrection.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ class CommandIterationUpdate : public itk::Command
typedef itk::SmartPointer<Self> Pointer;
itkNewMacro( Self );
protected:
CommandIterationUpdate()
{
};
CommandIterationUpdate() = default;
public:

void Execute(itk::Object *caller, const itk::EventObject & event) override
Expand Down
4 changes: 1 addition & 3 deletions Examples/antsMotionCorr.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,7 @@ class CommandIterationUpdate : public itk::Command
typedef itk::SmartPointer<Self> Pointer;
itkNewMacro( Self );
protected:
CommandIterationUpdate()
{
};
CommandIterationUpdate() = default;
public:

void Execute(itk::Object *caller, const itk::EventObject & event) override
Expand Down
4 changes: 1 addition & 3 deletions Examples/antsSliceRegularizedRegistration.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,7 @@ class CommandIterationUpdate : public itk::Command
typedef itk::SmartPointer<Self> Pointer;
itkNewMacro( Self );
protected:
CommandIterationUpdate()
{
};
CommandIterationUpdate() = default;
public:

void Execute(itk::Object *caller, const itk::EventObject & event) override
Expand Down
3 changes: 1 addition & 2 deletions Examples/itkantsRegistrationHelper.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ RegistrationHelper<TComputeType, VImageDimension>
template <typename TComputeType, unsigned VImageDimension>
RegistrationHelper<TComputeType, VImageDimension>
::~RegistrationHelper()
{
}
= default;

template <typename ImageType>
typename ImageType::Pointer PreprocessImage( typename ImageType::ConstPointer inputImage,
Expand Down
12 changes: 3 additions & 9 deletions ImageRegistration/ANTS_affine_registration2.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ class OptAffine
ignore_void_orgin = true;
};

~OptAffine()
{
};
~OptAffine() = default;

AffineTransformPointerType transform_initial;
MaskImagePointerType mask_fixed;
Expand Down Expand Up @@ -266,12 +264,8 @@ class RunningAffineCache
typedef TMaskObjectType MaskObjectType;
typedef typename MaskObjectType::Pointer MaskObjectPointerType;

RunningAffineCache()
{
};
~RunningAffineCache()
{
};
RunningAffineCache() = default;
~RunningAffineCache() = default;

MaskObjectPointerType mask_fixed_object;
ImagePyramidType fixed_image_pyramid;
Expand Down
8 changes: 3 additions & 5 deletions ImageRegistration/itkANTSAffine3DTransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,7 @@ class ANTSAffine3DTransform :
/* const OutputVectorType &offset); */
ANTSAffine3DTransform(unsigned int outputDims, unsigned int paramDims);
ANTSAffine3DTransform();
~ANTSAffine3DTransform() override
{
};
~ANTSAffine3DTransform() override = default;

void ComputeMatrix() override;

Expand All @@ -151,8 +149,8 @@ class ANTSAffine3DTransform :
void PrintSelf(std::ostream & os, Indent indent) const override;

private:
ANTSAffine3DTransform(const Self &); // purposely not implemented
void operator=(const Self &); // purposely not implemented
ANTSAffine3DTransform(const Self &) = delete;
void operator=(const Self &) = delete;

/** Rotation of the transformation. */
VnlQuaternionType m_Rotation;
Expand Down
4 changes: 2 additions & 2 deletions ImageRegistration/itkANTSCenteredAffine2DTransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ class ANTSCenteredAffine2DTransform :
}

private:
ANTSCenteredAffine2DTransform(const Self &); // purposely not implemented
void operator=(const Self &); // purposely not implemented
ANTSCenteredAffine2DTransform(const Self &) = delete;
void operator=(const Self &) = delete;

TScalarType m_Angle;
TScalarType m_S1;
Expand Down
3 changes: 1 addition & 2 deletions ImageRegistration/itkANTSCenteredAffine2DTransform.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ ANTSCenteredAffine2DTransform<TScalarType>::ANTSCenteredAffine2DTransform( unsig
template <typename TScalarType>
ANTSCenteredAffine2DTransform<TScalarType>::
~ANTSCenteredAffine2DTransform()
{
}
= default;

// Print self
template <typename TScalarType>
Expand Down
8 changes: 3 additions & 5 deletions ImageRegistration/itkANTSImageRegistrationOptimizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -2091,15 +2091,13 @@ class ANTSImageRegistrationOptimizer
}

ANTSImageRegistrationOptimizer();
~ANTSImageRegistrationOptimizer() override
{
}
~ANTSImageRegistrationOptimizer() override = default;

void PrintSelf( std::ostream& os, Indent indent ) const override;

private:
ANTSImageRegistrationOptimizer( const Self & ); // purposely not implemented
void operator=( const Self & ); // purposely not implemented
ANTSImageRegistrationOptimizer( const Self & ) = delete;
void operator=( const Self & ) = delete;

typename VelocityFieldInterpolatorType::Pointer m_VelocityFieldInterpolator;

Expand Down
8 changes: 3 additions & 5 deletions ImageRegistration/itkANTSImageTransformation.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,13 @@ class ANTSImageTransformation
itkBooleanMacro( WriteComponentImages );
protected:
ANTSImageTransformation();
~ANTSImageTransformation() override
{
}
~ANTSImageTransformation() override = default;

void PrintSelf( std::ostream& os, Indent indent ) const override;

private:
ANTSImageTransformation( const Self & ); // purposely not implemented
void operator=( const Self & ); // purposely not implemented
ANTSImageTransformation( const Self & ) = delete;
void operator=( const Self & ) = delete;

AffineTransformPointer m_AffineTransform;
AffineTransformPointer m_FixedImageAffineTransform;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -688,15 +688,13 @@ class AvantsMutualInformationRegistrationFunction :
protected:

AvantsMutualInformationRegistrationFunction();
~AvantsMutualInformationRegistrationFunction() override
{
};
~AvantsMutualInformationRegistrationFunction() override = default;
void PrintSelf(std::ostream& os, Indent indent) const override;

private:

AvantsMutualInformationRegistrationFunction(const Self &); // purposely not implemented
void operator=(const Self &); // purposely not implemented
AvantsMutualInformationRegistrationFunction(const Self &) = delete;
void operator=(const Self &) = delete;

typename JointPDFDerivativesType::Pointer m_JointPDFDerivatives;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,7 @@ class AvantsPDEDeformableRegistrationFunction :
this->m_RobustnessParameter = -1.e12;
}

~AvantsPDEDeformableRegistrationFunction() override
{
}
~AvantsPDEDeformableRegistrationFunction() override = default;

mutable double m_BestEnergy;
mutable double m_LastLastEnergy;
Expand All @@ -339,8 +337,8 @@ class AvantsPDEDeformableRegistrationFunction :

float m_RobustnessParameter;
private:
AvantsPDEDeformableRegistrationFunction(const Self &); // purposely not implemented
void operator=(const Self &); // purposely not implemented
AvantsPDEDeformableRegistrationFunction(const Self &) = delete;
void operator=(const Self &) = delete;
};
} // end namespace itk

Expand Down
8 changes: 3 additions & 5 deletions ImageRegistration/itkCrossCorrelationRegistrationFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,7 @@ class CrossCorrelationRegistrationFunction :

protected:
CrossCorrelationRegistrationFunction();
~CrossCorrelationRegistrationFunction() override
{
}
~CrossCorrelationRegistrationFunction() override = default;

void PrintSelf(std::ostream& os, Indent indent) const override;

Expand All @@ -357,8 +355,8 @@ class CrossCorrelationRegistrationFunction :
FixedImageNeighborhoodIteratorType m_FixedImageIterator;
};
private:
CrossCorrelationRegistrationFunction(const Self &); // purposely not implemented
void operator=(const Self &); // purposely not implemented
CrossCorrelationRegistrationFunction(const Self &) = delete;
void operator=(const Self &) = delete;

/** Cache fixed image information. */
typename TFixedImage::SpacingType m_FixedImageSpacing;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@ class ExpectationBasedPointSetRegistrationFunction :
void SetUpKDTrees(long whichlabel);

private:
ExpectationBasedPointSetRegistrationFunction(const Self &); // purposely not implemented
void operator=(const Self &); // purposely not implemented
ExpectationBasedPointSetRegistrationFunction(const Self &) = delete;
void operator=(const Self &) = delete;

/** Cache fixed image information. */
SpacingType m_FixedImageSpacing;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ class JensenHavrdaCharvatTsallisLabeledPointSetMetric :
void PrintSelf( std::ostream& os, Indent indent ) const;

private:
JensenHavrdaCharvatTsallisLabeledPointSetMetric(const Self &); // purposely not implemented
void operator=(const Self &); // purposely not implemented
JensenHavrdaCharvatTsallisLabeledPointSetMetric(const Self &) = delete;
void operator=(const Self &) = delete;

bool m_UseRegularizationTerm;
bool m_UseInputAsSamples;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,16 @@ class LabelImageGenericInterpolateImageFunction :

protected:
LabelImageGenericInterpolateImageFunction();
~LabelImageGenericInterpolateImageFunction() override{};
~LabelImageGenericInterpolateImageFunction() override= default;

std::vector<typename InternalInterpolatorType::Pointer> m_InternalInterpolators;
std::vector<typename LabelSelectionAdaptorType::Pointer> m_LabelSelectionAdaptors;
typedef std::set<typename TInputImage::PixelType> LabelSetType;
LabelSetType m_Labels;

private:
LabelImageGenericInterpolateImageFunction( const Self& ); //purposely not implemented
void operator=( const Self& ); //purposely not implemented
LabelImageGenericInterpolateImageFunction( const Self& ) = delete;
void operator=( const Self& ) = delete;

/**
* Evaluate function value at the given index
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ namespace itk
template<typename TInputImage, template<typename, typename> class TInterpolator , typename TCoordRep>
LabelImageGenericInterpolateImageFunction<TInputImage, TInterpolator, TCoordRep>
::LabelImageGenericInterpolateImageFunction()
{
}
= default;

template<typename TInputImage, template<typename, typename> class TInterpolator , typename TCoordRep>
void LabelImageGenericInterpolateImageFunction<TInputImage,TInterpolator, TCoordRep>
Expand Down
8 changes: 4 additions & 4 deletions ImageRegistration/itkLabelSelectionAdaptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ class ITK_EXPORT LabelSelectionImageAdaptor:public
}

protected:
LabelSelectionImageAdaptor() {}
~LabelSelectionImageAdaptor() override {}
LabelSelectionImageAdaptor() = default;
~LabelSelectionImageAdaptor() override = default;

private:
LabelSelectionImageAdaptor(const Self &); //purposely not implemented
void operator=(const Self &); //purposely not implemented
LabelSelectionImageAdaptor(const Self &) = delete;
void operator=(const Self &) = delete;
};
} // end namespace itk

Expand Down
8 changes: 3 additions & 5 deletions ImageRegistration/itkPICSLAdvancedNormalizationToolKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,13 @@ class PICSLAdvancedNormalizationToolKit

protected:
PICSLAdvancedNormalizationToolKit();
~PICSLAdvancedNormalizationToolKit() override
{
}
~PICSLAdvancedNormalizationToolKit() override = default;

void PrintSelf( std::ostream& os, Indent indent ) const override;

private:
PICSLAdvancedNormalizationToolKit( const Self & ); // purposely not implemented
void operator=( const Self & ); // purposely not implemented
PICSLAdvancedNormalizationToolKit( const Self & ) = delete;
void operator=( const Self & ) = delete;

ImagePointer SubsampleImage( ImagePointer, RealType );
ImagePointer PreprocessImage( ImagePointer );
Expand Down
8 changes: 3 additions & 5 deletions ImageRegistration/itkProbabilisticRegistrationFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,7 @@ class ProbabilisticRegistrationFunction :
float m_TEMP;
protected:
ProbabilisticRegistrationFunction();
~ProbabilisticRegistrationFunction() override
{
}
~ProbabilisticRegistrationFunction() override = default;

void PrintSelf(std::ostream& os, Indent indent) const override;

Expand Down Expand Up @@ -354,8 +352,8 @@ class ProbabilisticRegistrationFunction :
}

private:
ProbabilisticRegistrationFunction(const Self &); // purposely not implemented
void operator=(const Self &); // purposely not implemented
ProbabilisticRegistrationFunction(const Self &) = delete;
void operator=(const Self &) = delete;

/** Cache fixed image information. */
typename TFixedImage::SpacingType m_FixedImageSpacing;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -673,8 +673,8 @@ class SpatialMutualInformationRegistrationFunction :

private:

SpatialMutualInformationRegistrationFunction(const Self &); // purposely not implemented
void operator=(const Self &); // purposely not implemented
SpatialMutualInformationRegistrationFunction(const Self &) = delete;
void operator=(const Self &) = delete;

typename JointPDFType::Pointer m_JointHist;
typename JointPDFDerivativesType::Pointer m_JointPDFDerivatives;
Expand Down
4 changes: 2 additions & 2 deletions ImageRegistration/itkSyNDemonsRegistrationFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ class SyNDemonsRegistrationFunction :
double m_SumOfSquaredChange;
};
private:
SyNDemonsRegistrationFunction(const Self &); // purposely not implemented
void operator=(const Self &); // purposely not implemented
SyNDemonsRegistrationFunction(const Self &) = delete;
void operator=(const Self &) = delete;

/** Cache fixed image information. */
SpacingType m_FixedImageSpacing;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ class VectorParameterizedNeighborhoodOperatorImageFilter :
}

private:
VectorParameterizedNeighborhoodOperatorImageFilter(const Self &); // purposely not implemented
void operator=(const Self &); // purposely not implemented
VectorParameterizedNeighborhoodOperatorImageFilter(const Self &) = delete;
void operator=(const Self &) = delete;

/** Pointer to the internal operator used to filter the image. */
OperatorType m_Operator;
Expand Down
4 changes: 2 additions & 2 deletions ImageSegmentation/antsAtroposSegmentationImageFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -744,8 +744,8 @@ class AtroposSegmentationImageFilter :
void GenerateData() override;

private:
AtroposSegmentationImageFilter( const Self & ); // purposely not implemented
void operator=( const Self & ); // purposely not implemented
AtroposSegmentationImageFilter( const Self & ) = delete;
void operator=( const Self & ) = delete;

/**
* Initialize the segmentation labeling.
Expand Down
Loading

0 comments on commit 0836fb4

Please sign in to comment.