Skip to content

Commit

Permalink
STYLE: Update cpp classes to prefer = default to explicitly trivial i…
Browse files Browse the repository at this point in the history
…mplementations

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.

See https://www.slicer.org/w/index.php?title=Documentation/Nightly/Developers/Tutorials/MigrationGuide#C.2B.2B11:_Update_source_code_to_use_.3D_default
  • Loading branch information
hjmjohnson authored and jcfr committed Apr 15, 2020
1 parent b8b4c03 commit 4476737
Show file tree
Hide file tree
Showing 46 changed files with 65 additions and 143 deletions.
4 changes: 1 addition & 3 deletions Base/QTCore/qSlicerCoreApplication.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -680,9 +680,7 @@ qSlicerCoreApplication::qSlicerCoreApplication(
}

//-----------------------------------------------------------------------------
qSlicerCoreApplication::~qSlicerCoreApplication()
{
}
qSlicerCoreApplication::~qSlicerCoreApplication() = default;

//-----------------------------------------------------------------------------
qSlicerCoreApplication* qSlicerCoreApplication::application()
Expand Down
5 changes: 2 additions & 3 deletions Base/QTGUI/qSlicerAbstractModulePanel.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
class qSlicerAbstractModulePanelPrivate
{
public:
qSlicerAbstractModulePanelPrivate() {}
qSlicerAbstractModulePanelPrivate() = default;
qSlicerModuleManager* ModuleManager{nullptr};
};

Expand All @@ -38,8 +38,7 @@ qSlicerAbstractModulePanel::qSlicerAbstractModulePanel(QWidget* _parent, Qt::Win
}

//---------------------------------------------------------------------------
qSlicerAbstractModulePanel::~qSlicerAbstractModulePanel()
= default;
qSlicerAbstractModulePanel::~qSlicerAbstractModulePanel() = default;

//---------------------------------------------------------------------------
void qSlicerAbstractModulePanel::setModuleManager(qSlicerModuleManager* moduleManager)
Expand Down
2 changes: 1 addition & 1 deletion Base/QTGUI/qSlicerExtensionsInstallWidget_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ExtensionInstallWidgetWebChannelProxy : public QObject
{
Q_OBJECT
public:
ExtensionInstallWidgetWebChannelProxy(){}
ExtensionInstallWidgetWebChannelProxy() = default;
qSlicerExtensionsInstallWidget* InstallWidget{nullptr};
public slots:
void refresh();
Expand Down
2 changes: 1 addition & 1 deletion Libs/MRML/Core/Testing/vtkMRMLSceneTest1.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class vtkMRMLCustomNode
int ResetCount{0};

protected:
vtkMRMLCustomNode(){}
vtkMRMLCustomNode() = default;
~vtkMRMLCustomNode() override = default;
vtkMRMLCustomNode(const vtkMRMLCustomNode&);
void operator=(const vtkMRMLCustomNode&);
Expand Down
2 changes: 1 addition & 1 deletion Libs/MRML/Core/Testing/vtkMRMLStorageNodeTest1.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class vtkMRMLStorageNodeTestHelper1 : public vtkMRMLStorageNode
const char* SupportedClass{nullptr};
int ReadDataReturnValue{0};
protected:
vtkMRMLStorageNodeTestHelper1() {}
vtkMRMLStorageNodeTestHelper1() = default;
};
vtkStandardNewMacro(vtkMRMLStorageNodeTestHelper1);

Expand Down
2 changes: 1 addition & 1 deletion Libs/MRML/Core/vtkCodedEntry.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ or http://www.slicer.org/copyright/copyright.txt for details.
vtkStandardNewMacro(vtkCodedEntry);

//----------------------------------------------------------------------------
vtkCodedEntry::vtkCodedEntry() { }
vtkCodedEntry::vtkCodedEntry() = default;

//----------------------------------------------------------------------------
vtkCodedEntry::~vtkCodedEntry()
Expand Down
2 changes: 1 addition & 1 deletion Libs/MRML/Core/vtkMRMLFolderDisplayNode.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
vtkMRMLNodeNewMacro(vtkMRMLFolderDisplayNode);

//-----------------------------------------------------------------------------
vtkMRMLFolderDisplayNode::vtkMRMLFolderDisplayNode() { }
vtkMRMLFolderDisplayNode::vtkMRMLFolderDisplayNode() = default;

//-----------------------------------------------------------------------------
vtkMRMLFolderDisplayNode::~vtkMRMLFolderDisplayNode() = default;
Expand Down
2 changes: 1 addition & 1 deletion Libs/MRML/Core/vtkMRMLParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class VTK_MRML_EXPORT vtkMRMLParser : public vtkXMLParser
void SetNodeCollection(vtkCollection* scene) {this->NodeCollection = scene;};

protected:
vtkMRMLParser() {};
vtkMRMLParser() = default;;
~vtkMRMLParser() override = default;
vtkMRMLParser(const vtkMRMLParser&);
void operator=(const vtkMRMLParser&);
Expand Down
2 changes: 1 addition & 1 deletion Libs/MRML/Core/vtkMRMLScalarVolumeNode.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ vtkCxxSetObjectMacro(vtkMRMLScalarVolumeNode, VoxelValueQuantity, vtkCodedEntry)
vtkCxxSetObjectMacro(vtkMRMLScalarVolumeNode, VoxelValueUnits, vtkCodedEntry);

//----------------------------------------------------------------------------
vtkMRMLScalarVolumeNode::vtkMRMLScalarVolumeNode() { }
vtkMRMLScalarVolumeNode::vtkMRMLScalarVolumeNode() = default;

//----------------------------------------------------------------------------
vtkMRMLScalarVolumeNode::~vtkMRMLScalarVolumeNode()
Expand Down
5 changes: 2 additions & 3 deletions Libs/MRML/Core/vtkMRMLSegmentationStorageNode.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,10 @@ static const int SINGLE_SEGMENT_INDEX = -1; // used as segment index when there
vtkMRMLNodeNewMacro(vtkMRMLSegmentationStorageNode);

//----------------------------------------------------------------------------
vtkMRMLSegmentationStorageNode::vtkMRMLSegmentationStorageNode() { }
vtkMRMLSegmentationStorageNode::vtkMRMLSegmentationStorageNode() = default;

//----------------------------------------------------------------------------
vtkMRMLSegmentationStorageNode::~vtkMRMLSegmentationStorageNode()
= default;
vtkMRMLSegmentationStorageNode::~vtkMRMLSegmentationStorageNode() = default;

//----------------------------------------------------------------------------
void vtkMRMLSegmentationStorageNode::PrintSelf(ostream& os, vtkIndent indent)
Expand Down
4 changes: 1 addition & 3 deletions Libs/MRML/Core/vtkMRMLSelectionNode.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ vtkMRMLSelectionNode::vtkMRMLSelectionNode()
}

//----------------------------------------------------------------------------
vtkMRMLSelectionNode::~vtkMRMLSelectionNode()
{
}
vtkMRMLSelectionNode::~vtkMRMLSelectionNode() = default;

//----------------------------------------------------------------------------
void vtkMRMLSelectionNode::WriteXML(ostream& of, int nIndent)
Expand Down
8 changes: 2 additions & 6 deletions Libs/MRML/Core/vtkMRMLTextStorageNode.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,10 @@
vtkMRMLNodeNewMacro(vtkMRMLTextStorageNode);

//----------------------------------------------------------------------------
vtkMRMLTextStorageNode::vtkMRMLTextStorageNode()
{
}
vtkMRMLTextStorageNode::vtkMRMLTextStorageNode() = default;

//----------------------------------------------------------------------------
vtkMRMLTextStorageNode::~vtkMRMLTextStorageNode()
{
}
vtkMRMLTextStorageNode::~vtkMRMLTextStorageNode() = default;

//----------------------------------------------------------------------------
bool vtkMRMLTextStorageNode::CanReadInReferenceNode(vtkMRMLNode* refNode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ class vtkRenderRequestCallback : public vtkCommand
//std::cout << "RenderRequestCount [" << this->RenderRequestCount << "]" << std::endl;
}
protected:
vtkRenderRequestCallback() {}
vtkRenderRequestCallback() = default;
vtkRenderer * Renderer{nullptr};
int RenderRequestCount{0};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ class vtkRenderCallback : public vtkCommand
{
this->RenderWindow->Render();
}
vtkRenderCallback() {}
vtkRenderCallback() = default;
vtkRenderWindow *RenderWindow{nullptr};
};

Expand Down
4 changes: 1 addition & 3 deletions Libs/MRML/DisplayableManager/vtkMRMLViewInteractorStyle.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ vtkMRMLViewInteractorStyle::vtkMRMLViewInteractorStyle()
}

//----------------------------------------------------------------------------
vtkMRMLViewInteractorStyle::~vtkMRMLViewInteractorStyle()
{
}
vtkMRMLViewInteractorStyle::~vtkMRMLViewInteractorStyle() = default;

//----------------------------------------------------------------------------
void vtkMRMLViewInteractorStyle::PrintSelf(ostream& os, vtkIndent indent)
Expand Down
5 changes: 2 additions & 3 deletions Libs/MRML/Logic/vtkMRMLApplicationLogic.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ vtkMRMLApplicationLogic::vtkInternal::vtkInternal(vtkMRMLApplicationLogic* exter
}

//----------------------------------------------------------------------------
vtkMRMLApplicationLogic::vtkInternal::~vtkInternal()
= default;
vtkMRMLApplicationLogic::vtkInternal::~vtkInternal() = default;

//----------------------------------------------------------------------------
void vtkMRMLApplicationLogic::vtkInternal::PropagateVolumeSelection(int layer, int fit)
Expand Down Expand Up @@ -1162,7 +1161,7 @@ int vtkMRMLApplicationLogic::LoadDefaultParameterSets(vtkMRMLScene* scene,

//----------------------------------------------------------------------------
vtkMRMLApplicationLogic
::InvokeRequest::InvokeRequest() { }
::InvokeRequest::InvokeRequest() = default;

//----------------------------------------------------------------------------
void vtkMRMLApplicationLogic
Expand Down
2 changes: 1 addition & 1 deletion Libs/vtkITK/itkMorphologicalContourInterpolator.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ class MorphologicalContourInterpolator:

protected:
MorphologicalContourInterpolator();
~MorphologicalContourInterpolator() override {}
~MorphologicalContourInterpolator() override = default;
typename TImage::PixelType m_Label;
int m_Axis{ -1 };
bool m_HeuristicAlignment{ true };
Expand Down
2 changes: 1 addition & 1 deletion Libs/vtkITK/itkMorphologicalContourInterpolator.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ class MatchesID
typename TImage::PixelType m_ID;

public:
MatchesID() {}
MatchesID() = default;
MatchesID( typename TImage::PixelType id )
: m_ID( id )
{}
Expand Down
3 changes: 1 addition & 2 deletions Libs/vtkITK/vtkITKMorphologicalContourInterpolator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@

vtkStandardNewMacro(vtkITKMorphologicalContourInterpolator);

vtkITKMorphologicalContourInterpolator::vtkITKMorphologicalContourInterpolator() { }

vtkITKMorphologicalContourInterpolator::vtkITKMorphologicalContourInterpolator() = default;
vtkITKMorphologicalContourInterpolator::~vtkITKMorphologicalContourInterpolator() = default;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ namespace {
class EdgeLocatorNode
{
public:
EdgeLocatorNode() {}
EdgeLocatorNode() = default;

// Free the list that this node is the head of
void FreeList() {
Expand Down
2 changes: 1 addition & 1 deletion Libs/vtkSegmentationCore/vtkSegmentationConverterRule.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include <vtkSegment.h>

//----------------------------------------------------------------------------
vtkSegmentationConverterRule::vtkSegmentationConverterRule() { }
vtkSegmentationConverterRule::vtkSegmentationConverterRule() = default;

//----------------------------------------------------------------------------
vtkSegmentationConverterRule::~vtkSegmentationConverterRule()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ AffineImageToImageRegistrationMethod<TImage>::AffineImageToImageRegistrationMeth
}

template <class TImage>
AffineImageToImageRegistrationMethod<TImage>::~AffineImageToImageRegistrationMethod()
{
}
AffineImageToImageRegistrationMethod<TImage>::~AffineImageToImageRegistrationMethod() = default;

template <class TImage>
void AffineImageToImageRegistrationMethod<TImage>::GenerateData()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,7 @@ class AnisotropicSimilarity3DTransform :
AnisotropicSimilarity3DTransform(const MatrixType & matrix, const OutputVectorType & offset);
AnisotropicSimilarity3DTransform(unsigned int paramDim);
AnisotropicSimilarity3DTransform();
~AnisotropicSimilarity3DTransform() override
{
};
~AnisotropicSimilarity3DTransform() override = default;;

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,7 @@ class AnisotropicSimilarityLandmarkBasedTransformInitializer :

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ namespace itk

template <class TTransform, class TFixedImage, class TMovingImage>
AnisotropicSimilarityLandmarkBasedTransformInitializer<TTransform, TFixedImage, TMovingImage>
::AnisotropicSimilarityLandmarkBasedTransformInitializer()
{
}
::AnisotropicSimilarityLandmarkBasedTransformInitializer() = default;

template <class TTransform, class TFixedImage, class TMovingImage>
void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,7 @@ protected:
m_UpdateInterval = 1;
m_DontShowParameters = false;
}
~BSplineImageRegistrationViewer() override
{
}
~BSplineImageRegistrationViewer() override = default;

};

Expand All @@ -133,9 +131,7 @@ BSplineImageToImageRegistrationMethod<TImage>::BSplineImageToImageRegistrationMe
}

template <class TImage>
BSplineImageToImageRegistrationMethod<TImage>::~BSplineImageToImageRegistrationMethod()
{
}
BSplineImageToImageRegistrationMethod<TImage>::~BSplineImageToImageRegistrationMethod() = default;

template <class TImage>
void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ ImageRegionMomentsCalculator<TImage>::ImageRegionMomentsCalculator()
// Destructor
template <class TImage>
ImageRegionMomentsCalculator<TImage>::
~ImageRegionMomentsCalculator()
{
}
~ImageRegionMomentsCalculator() = default;

template <class TInputImage>
void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,7 @@ ImageToImageRegistrationHelper<TImage>

template <class TImage>
ImageToImageRegistrationHelper<TImage>
::~ImageToImageRegistrationHelper()
{
}
::~ImageToImageRegistrationHelper() = default;

template <class TImage>
void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ ImageToImageRegistrationMethod<TImage>::ImageToImageRegistrationMethod()
}

template <class TImage>
ImageToImageRegistrationMethod<TImage>::~ImageToImageRegistrationMethod()
{
}
ImageToImageRegistrationMethod<TImage>::~ImageToImageRegistrationMethod() = default;

template <class TImage>
void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ InitialImageToImageRegistrationMethod<TImage>::InitialImageToImageRegistrationMe
}

template <class TImage>
InitialImageToImageRegistrationMethod<TImage>::~InitialImageToImageRegistrationMethod()
{
}
InitialImageToImageRegistrationMethod<TImage>::~InitialImageToImageRegistrationMethod() = default;

/** Only the GenerateData() method should be overloaded. The Update() method
* must not be overloaded */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,7 @@ protected:
m_UpdateInterval = 1;
m_DontShowParameters = false;
}
~ImageRegistrationViewer() override
{
}
~ImageRegistrationViewer() override = default;

};

Expand Down Expand Up @@ -176,9 +174,7 @@ OptimizedImageToImageRegistrationMethod<TImage>::OptimizedImageToImageRegistrati
}

template <class TImage>
OptimizedImageToImageRegistrationMethod<TImage>::~OptimizedImageToImageRegistrationMethod()
{
}
OptimizedImageToImageRegistrationMethod<TImage>::~OptimizedImageToImageRegistrationMethod() = default;

template <class TImage>
void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ namespace itk
class DCMTKSequence
{
public:
DCMTKSequence() {}
DCMTKSequence() = default;
void SetDcmSequenceOfItems(DcmSequenceOfItems *seq);
int card();
int GetSequence(unsigned long index,
Expand Down Expand Up @@ -144,7 +144,7 @@ class DCMTKFileReader
public:
typedef DCMTKFileReader Self;

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

void SetFileName(const std::string &fileName);
Expand Down
Loading

0 comments on commit 4476737

Please sign in to comment.