Skip to content

Commit a5b7960

Browse files
committed
STYLE: Remove this->MakeOutput(0) calls from constructors
Analogue to ITK pull request InsightSoftwareConsortium/ITK#4654 Following C++ Core Guidelines, February 15, 2024, "Don’t call virtual functions in constructors and destructors", https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rc-ctor-virtual
1 parent 5e47bcc commit a5b7960

File tree

3 files changed

+3
-12
lines changed

3 files changed

+3
-12
lines changed

Common/ImageSamplers/itkImageSamplerBase.hxx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -405,11 +405,8 @@ template <class TInputImage>
405405
ImageSamplerBase<TInputImage>::ImageSamplerBase()
406406
{
407407
this->ProcessObject::SetNumberOfRequiredInputs(1);
408-
409-
OutputVectorContainerPointer output = dynamic_cast<OutputVectorContainerType *>(this->MakeOutput(0).GetPointer());
410-
411408
this->ProcessObject::SetNumberOfRequiredOutputs(1);
412-
this->ProcessObject::SetNthOutput(0, output.GetPointer());
409+
this->ProcessObject::SetNthOutput(0, OutputVectorContainerType::New().GetPointer());
413410

414411
} // end Constructor
415412

Common/ImageSamplers/itkVectorContainerSource.hxx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,8 @@ namespace itk
3030
template <class TOutputVectorContainer>
3131
VectorContainerSource<TOutputVectorContainer>::VectorContainerSource()
3232
{
33-
// Create the output. We use static_cast<> here because we know the default
34-
// output must be of type TOutputVectorContainer
35-
OutputVectorContainerPointer output = static_cast<TOutputVectorContainer *>(this->MakeOutput(0).GetPointer());
36-
3733
this->ProcessObject::SetNumberOfRequiredOutputs(1);
38-
this->ProcessObject::SetNthOutput(0, output.GetPointer());
34+
this->ProcessObject::SetNthOutput(0, TOutputVectorContainer::New().GetPointer());
3935

4036
this->m_GenerateDataRegion = 0;
4137
this->m_GenerateDataNumberOfRegions = 0;

Common/itkMultiResolutionImageRegistrationMethod2.hxx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,7 @@ MultiResolutionImageRegistrationMethod2<TFixedImage, TMovingImage>::MultiResolut
7979
this->m_InitialTransformParametersOfNextLevel.Fill(0.0f);
8080
this->m_LastTransformParameters.Fill(0.0f);
8181

82-
TransformOutputPointer transformDecorator = static_cast<TransformOutputType *>(this->MakeOutput(0).GetPointer());
83-
84-
this->ProcessObject::SetNthOutput(0, transformDecorator.GetPointer());
82+
this->ProcessObject::SetNthOutput(0, TransformOutputType::New().GetPointer());
8583

8684
} // end Constructor
8785

0 commit comments

Comments
 (0)