Skip to content

Commit

Permalink
STYLE: In code examples, use auto for variables initialized by New()
Browse files Browse the repository at this point in the history
In accordance with the ITK Coding Style, section The auto Keyword:

> The `auto` keyword should be used to specify a type in the following cases:
> -  The type is duplicated on the left side of an initialization when
>    it is mandated on the right side, e.g. when there is an explicit
>    cast or initializing with `new` or ITK's `::New()`.
...

Suggested by Jon Haitz Legarreta Gorroño as part of the review of
pull request InsightSoftwareConsortium/ITK#2826
"STYLE: Use `auto` for declaration of variables initialized by `New()`"
  • Loading branch information
N-Dekker committed Oct 20, 2021
1 parent fb9eb1e commit 49c2bf0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions SoftwareGuide/Latex/Appendices/CodingStyleGuide.tex
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,7 @@ \subsubsection{Temporary Variable Naming}
// on into a temporary image to use as the input to the mini-pipeline. This
// avoids a complete copy of the image.
typename OutputImageType::Pointer output = this->GetOutput();
typename OutputImageType::Pointer tmp = OutputImageType::New();
auto tmp = OutputImageType::New();
tmp->SetRequestedRegion( output->GetRequestedRegion() );
tmp->SetBufferedRegion( output->GetBufferedRegion() );
tmp->SetLargestPossibleRegion( output->GetLargestPossibleRegion() );
Expand Down Expand Up @@ -2069,7 +2069,7 @@ \subsection{Indentation and Tabs}
this->AllocateOutputs();
// Create a process accumulator for tracking the progress of this minipipeline.
ProgressAccumulator::Pointer progress = ProgressAccumulator::New();
auto progress = ProgressAccumulator::New();
progress->SetMiniPipelineFilter( this );
...
Expand Down Expand Up @@ -2825,7 +2825,7 @@ \subsection{Empty Lines}
// Write the output
using WriterType = itk::ImageFileWriter< OutputImageType >;
WriterType::Pointer writer = WriterType::New();
auto writer = WriterType::New();
writer->SetFileName( argv[2] );
writer->SetInput( hMinimaFilter->GetOutput() );
Expand Down
4 changes: 2 additions & 2 deletions SoftwareGuide/Latex/Architecture/SystemOverview.tex
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ \subsection{Smart Pointers and Memory Management}

// here an interpolator is created and associated to the
// "interp" SmartPointer.
InterpolatorType::Pointer interp = InterpolatorType::New();
auto interp = InterpolatorType::New();

} /* <------ End of scope */
\end{minted}
Expand Down Expand Up @@ -823,7 +823,7 @@ \section{Wrapping}

using ImageType = itk::Image< PixelType, Dimension >;
using ReaderType = itk::ImageFileReader< ImageType >;
ReaderType::Pointer reader = ReaderType::New();
auto reader = ReaderType::New();
reader->SetFileName( inputImage );

using StructuringElementType = itk::FlatStructuringElement< Dimension >;
Expand Down

0 comments on commit 49c2bf0

Please sign in to comment.