Skip to content

Commit 49c2bf0

Browse files
committed
STYLE: In code examples, use auto for variables initialized by New()
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()`"
1 parent fb9eb1e commit 49c2bf0

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

SoftwareGuide/Latex/Appendices/CodingStyleGuide.tex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,7 @@ \subsubsection{Temporary Variable Naming}
915915
// on into a temporary image to use as the input to the mini-pipeline. This
916916
// avoids a complete copy of the image.
917917
typename OutputImageType::Pointer output = this->GetOutput();
918-
typename OutputImageType::Pointer tmp = OutputImageType::New();
918+
auto tmp = OutputImageType::New();
919919
tmp->SetRequestedRegion( output->GetRequestedRegion() );
920920
tmp->SetBufferedRegion( output->GetBufferedRegion() );
921921
tmp->SetLargestPossibleRegion( output->GetLargestPossibleRegion() );
@@ -2069,7 +2069,7 @@ \subsection{Indentation and Tabs}
20692069
this->AllocateOutputs();
20702070
20712071
// Create a process accumulator for tracking the progress of this minipipeline.
2072-
ProgressAccumulator::Pointer progress = ProgressAccumulator::New();
2072+
auto progress = ProgressAccumulator::New();
20732073
progress->SetMiniPipelineFilter( this );
20742074
20752075
...
@@ -2825,7 +2825,7 @@ \subsection{Empty Lines}
28252825
28262826
// Write the output
28272827
using WriterType = itk::ImageFileWriter< OutputImageType >;
2828-
WriterType::Pointer writer = WriterType::New();
2828+
auto writer = WriterType::New();
28292829
writer->SetFileName( argv[2] );
28302830
writer->SetInput( hMinimaFilter->GetOutput() );
28312831

SoftwareGuide/Latex/Architecture/SystemOverview.tex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ \subsection{Smart Pointers and Memory Management}
255255

256256
// here an interpolator is created and associated to the
257257
// "interp" SmartPointer.
258-
InterpolatorType::Pointer interp = InterpolatorType::New();
258+
auto interp = InterpolatorType::New();
259259

260260
} /* <------ End of scope */
261261
\end{minted}
@@ -823,7 +823,7 @@ \section{Wrapping}
823823

824824
using ImageType = itk::Image< PixelType, Dimension >;
825825
using ReaderType = itk::ImageFileReader< ImageType >;
826-
ReaderType::Pointer reader = ReaderType::New();
826+
auto reader = ReaderType::New();
827827
reader->SetFileName( inputImage );
828828

829829
using StructuringElementType = itk::FlatStructuringElement< Dimension >;

0 commit comments

Comments
 (0)