Skip to content

Commit

Permalink
STYLE: Prefer = delete to explicitly trivial implementations
Browse files Browse the repository at this point in the history
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.

See https://www.slicer.org/w/index.php?title=Documentation/Nightly/Developers/Tutorials/MigrationGuide#C.2B.2B11:_Update_source_code_to_use_.3D_delete
  • Loading branch information
hjmjohnson authored and jcfr committed Apr 15, 2020
1 parent 4476737 commit 1138fba
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ class AnisotropicSimilarity3DTransform :
/** New macro for creation of through a Smart Pointer. */
itkNewMacro( Self );

/** Explicitly deleted functions belong in the public interface */
AnisotropicSimilarity3DTransform(const Self &) = delete;
void operator=(const Self &) = delete;

/** Run-time type information (and related methods). */
itkTypeMacro( AnisotropicSimilarity3DTransform, VersorRigid3DTransform );

Expand Down Expand Up @@ -146,8 +150,6 @@ class AnisotropicSimilarity3DTransform :
void ComputeMatrixParameters() override;

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

VectorType m_Scale;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ class RigidImageToImageRegistrationMethod

itkNewMacro( Self );

/** Explicitly deleted functions belong in the public interface */
RigidImageToImageRegistrationMethod( const Self & ) = delete;
void operator =( const Self & ) = delete;

//
// Typedefs from Superclass
//
Expand Down Expand Up @@ -120,12 +124,6 @@ class RigidImageToImageRegistrationMethod
~RigidImageToImageRegistrationMethod() override;

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

private:

RigidImageToImageRegistrationMethod( const Self & ); // Purposely not implemented
void operator =( const Self & ); // Purposely not implemented

};

} // end namespace itk
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ class DiffusionTensor3DAbsCorrectionFilter :
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;

/** Explicitly deleted functions belong in the public interface */
DiffusionTensor3DAbsCorrectionFilter( const Self & ) = delete;
void operator=( const Self & ) = delete;

/** Run-time type information (and related methods). */
itkTypeMacro(DiffusionTensor3DAbsCorrectionFilter, UnaryFunctorImageFilter);

Expand All @@ -124,10 +128,6 @@ class DiffusionTensor3DAbsCorrectionFilter :
protected:
DiffusionTensor3DAbsCorrectionFilter() = default;
~DiffusionTensor3DAbsCorrectionFilter() override = default;
private:
DiffusionTensor3DAbsCorrectionFilter( const Self & ); // purposely not implemented
void operator=( const Self & ); // purposely not implemented

};

} // end namespace itk
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ class DiffusionTensor3DNearestCorrectionFilter :
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;

/** Explicitly deleted functions belong in the public interface */
DiffusionTensor3DNearestCorrectionFilter( const Self & ) = delete;
void operator=( const Self & ) = delete;

/** Run-time type information (and related methods). */
itkTypeMacro(DiffusionTensor3DNearestCorrectionFilter, UnaryFunctorImageFilter);

Expand All @@ -141,10 +145,6 @@ class DiffusionTensor3DNearestCorrectionFilter :
protected:
DiffusionTensor3DNearestCorrectionFilter() = default;
~DiffusionTensor3DNearestCorrectionFilter() override = default;
private:
DiffusionTensor3DNearestCorrectionFilter( const Self & ); // purposely not implemented
void operator=( const Self & ); // purposely not implemented

};

} // end namespace itk
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ class DiffusionTensor3DZeroCorrectionFilter :
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;

/** Explicitly deleted functions belong in the public interface */
DiffusionTensor3DZeroCorrectionFilter( const Self & ) = delete;
void operator=( const Self & ) = delete;

/** Run-time type information (and related methods). */
itkTypeMacro(DiffusionTensor3DZeroCorrectionFilter, UnaryFunctorImageFilter);

Expand All @@ -124,10 +128,6 @@ class DiffusionTensor3DZeroCorrectionFilter :
protected:
DiffusionTensor3DZeroCorrectionFilter() = default;
~DiffusionTensor3DZeroCorrectionFilter() override = default;
private:
DiffusionTensor3DZeroCorrectionFilter( const Self & ); // purposely not implemented
void operator=( const Self & ); // purposely not implemented

};

} // end namespace itk
Expand Down

0 comments on commit 1138fba

Please sign in to comment.