Skip to content

Commit babece9

Browse files
jhlegarretadzenanz
authored andcommitted
STYLE: Avoid repeating parent aliases in operator classes
Avoid repeating parent aliases in `Common` operator classes whenever possible. Use the preferred `using typename Superclass::{TypeAlias}` aliasing form for the relevant type. Make the `CoefficientVector` type be public in `itk::NeighborhoodOperator` so that child classes can have access to it.
1 parent a4693b5 commit babece9

10 files changed

+32
-34
lines changed

Modules/Core/Common/include/itkAnnulusOperator.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ class ITK_TEMPLATE_EXPORT AnnulusOperator : public NeighborhoodOperator<TPixel,
7878

7979
/** Additional type aliases. */
8080
using PixelType = TPixel;
81-
using SizeType = typename Superclass::SizeType;
82-
using OffsetType = typename Superclass::OffsetType;
81+
using typename Superclass::SizeType;
82+
using typename Superclass::OffsetType;
8383
using SpacingType = Vector<double, TDimension>;
8484

8585
/** Run-time type information (and related methods). */
@@ -222,9 +222,8 @@ class ITK_TEMPLATE_EXPORT AnnulusOperator : public NeighborhoodOperator<TPixel,
222222
}
223223

224224
protected:
225-
/** Typedef support for coefficient vector type. Necessary to
226-
* work around compiler bug on VC++. */
227-
using CoefficientVector = typename Superclass::CoefficientVector;
225+
/** Type alias support for coefficient vector type.*/
226+
using typename Superclass::CoefficientVector;
228227

229228
/** Calculates operator coefficients. */
230229
CoefficientVector

Modules/Core/Common/include/itkBackwardDifferenceOperator.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,12 @@ class ITK_TEMPLATE_EXPORT BackwardDifferenceOperator : public NeighborhoodOperat
5555
/** Run-time type information (and related methods). */
5656
itkTypeMacro(BackwardDifferenceOperator, NeighborhoodOperator);
5757

58-
using PixelType = typename Superclass::PixelType;
58+
/** Type alias support for pixel type. */
59+
using PixelType = TPixel;
5960

6061
protected:
61-
/** Necessary to work around a compiler bug in VC++. */
62-
using CoefficientVector = typename Superclass::CoefficientVector;
62+
/** Type alias support for coefficient vector type.*/
63+
using typename Superclass::CoefficientVector;
6364

6465
/** Calculates operator coefficients. */
6566
CoefficientVector

Modules/Core/Common/include/itkDerivativeOperator.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ class ITK_TEMPLATE_EXPORT DerivativeOperator : public NeighborhoodOperator<TPixe
7676
/** Run-time type information (and related methods). */
7777
itkTypeMacro(DerivativeOperator, NeighborhoodOperator);
7878

79-
using PixelType = TPixel;
80-
using PixelRealType = typename Superclass::PixelRealType;
79+
/** Type alias support for pixel real type.*/
80+
using typename Superclass::PixelRealType;
8181

8282
/** Sets the order of the derivative. */
8383
void
@@ -102,9 +102,8 @@ class ITK_TEMPLATE_EXPORT DerivativeOperator : public NeighborhoodOperator<TPixe
102102
}
103103

104104
protected:
105-
/** Typedef support for coefficient vector type. Necessary to
106-
* work around compiler bug on VC++. */
107-
using CoefficientVector = typename Superclass::CoefficientVector;
105+
/** Type alias support for coefficient vector type.*/
106+
using typename Superclass::CoefficientVector;
108107

109108
/** Calculates operator coefficients. */
110109
CoefficientVector

Modules/Core/Common/include/itkForwardDifferenceOperator.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,12 @@ class ITK_TEMPLATE_EXPORT ForwardDifferenceOperator : public NeighborhoodOperato
5454
/** Run-time type information (and related methods). */
5555
itkTypeMacro(ForwardDifferenceOperator, NeighborhoodOperator);
5656

57-
using PixelType = typename Superclass::PixelType;
57+
/** Type alias support for pixel type. */
58+
using PixelType = TPixel;
5859

5960
protected:
60-
/** Necessary to work around VC++ compiler bug. */
61-
using CoefficientVector = typename Superclass::CoefficientVector;
61+
/** Type alias support for coefficient vector type.*/
62+
using typename Superclass::CoefficientVector;
6263

6364
/** Calculates operator coefficients. */
6465
CoefficientVector

Modules/Core/Common/include/itkGaussianDerivativeOperator.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,8 @@ class ITK_TEMPLATE_EXPORT GaussianDerivativeOperator : public NeighborhoodOperat
210210
PrintSelf(std::ostream & os, Indent i) const override;
211211

212212
protected:
213-
using CoefficientVector = typename Superclass::CoefficientVector;
213+
/** Type alias support for coefficient vector type.*/
214+
using typename Superclass::CoefficientVector;
214215

215216
/** Returns the value of the modified Bessel function I0(x) at a point x >= 0.
216217
*/

Modules/Core/Common/include/itkGaussianOperator.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,6 @@ class ITK_TEMPLATE_EXPORT GaussianOperator : public NeighborhoodOperator<TPixel,
141141
Superclass::PrintSelf(os, i.GetNextIndent());
142142
}
143143

144-
protected:
145-
using CoefficientVector = typename Superclass::CoefficientVector;
146-
147144
public:
148145
/** Returns the value of the modified Bessel function I0(x) at a point x >= 0.
149146
*/
@@ -161,6 +158,9 @@ class ITK_TEMPLATE_EXPORT GaussianOperator : public NeighborhoodOperator<TPixel,
161158
ModifiedBesselI(int, double);
162159

163160
protected:
161+
/** Type alias support for coefficient vector type.*/
162+
using typename Superclass::CoefficientVector;
163+
164164
/** Calculates operator coefficients. */
165165
CoefficientVector
166166
GenerateCoefficients() override;

Modules/Core/Common/include/itkImageKernelOperator.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ class ITK_TEMPLATE_EXPORT ImageKernelOperator : public NeighborhoodOperator<TPix
5454
using Superclass = NeighborhoodOperator<TPixel, VDimension, TAllocator>;
5555

5656
using ImageType = Image<TPixel, VDimension>;
57-
using SizeType = typename Superclass::SizeType;
58-
using CoefficientVector = typename Superclass::CoefficientVector;
5957

6058
/** Run-time type information (and related methods). */
6159
itkTypeMacro(ImageKernelOperator, NeighborhoodOperator);
@@ -79,6 +77,9 @@ class ITK_TEMPLATE_EXPORT ImageKernelOperator : public NeighborhoodOperator<TPix
7977
}
8078

8179
protected:
80+
/** Type alias support for coefficient vector type.*/
81+
using typename Superclass::CoefficientVector;
82+
8283
/** Calculates operator coefficients. */
8384
CoefficientVector
8485
GenerateCoefficients() override;

Modules/Core/Common/include/itkLaplacianOperator.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ class ITK_TEMPLATE_EXPORT LaplacianOperator : public NeighborhoodOperator<TPixel
7474
/** Run-time type information (and related methods). */
7575
itkTypeMacro(LaplacianOperator, NeighborhoodOperator);
7676

77-
using PixelType = TPixel;
7877
using SizeType = typename Superclass::SizeType;
7978

8079
LaplacianOperator()
@@ -105,9 +104,8 @@ class ITK_TEMPLATE_EXPORT LaplacianOperator : public NeighborhoodOperator<TPixel
105104
itkGetConstMacro(DerivativeScalings, const double *);
106105

107106
protected:
108-
/** Alias support for coefficient vector type. Necessary to
109-
* work around compiler bug on VC++. */
110-
using CoefficientVector = typename Superclass::CoefficientVector;
107+
/** Type alias support for coefficient vector type.*/
108+
using typename Superclass::CoefficientVector;
111109

112110
/** Calculates operator coefficients. */
113111
CoefficientVector

Modules/Core/Common/include/itkNeighborhoodOperator.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ class ITK_TEMPLATE_EXPORT NeighborhoodOperator : public Neighborhood<TPixel, VDi
8787
/** Slice iterator type alias support */
8888
using SliceIteratorType = SliceIterator<TPixel, Self>;
8989

90+
using PixelRealType = typename NumericTraits<TPixel>::RealType;
91+
9092
/** Sets the dimensional direction of a directional operator. */
9193
void
9294
SetDirection(const unsigned long & direction)
@@ -135,16 +137,14 @@ class ITK_TEMPLATE_EXPORT NeighborhoodOperator : public Neighborhood<TPixel, VDi
135137
Superclass::PrintSelf(os, i.GetNextIndent());
136138
}
137139

138-
using PixelRealType = typename NumericTraits<TPixel>::RealType;
139-
140140
/** Multiplies all of the coefficients of the kernel by a single scalar value.
141141
*/
142142
void ScaleCoefficients(PixelRealType);
143143

144144
protected:
145-
/** Typedef support for coefficient vector type. Necessary
145+
/** Type alias support for coefficient vector type. Necessary
146146
* to fix bug in the microsoft VC++ compiler. */
147-
using CoefficientVector = std::vector<PixelRealType>;
147+
using CoefficientVector = typename std::vector<PixelRealType>;
148148

149149
/** A subclass-specific algorithm that computes the coefficients
150150
* of the operator. */

Modules/Core/Common/include/itkSobelOperator.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,8 @@ class ITK_TEMPLATE_EXPORT SobelOperator : public NeighborhoodOperator<TPixel, VD
132132
}
133133

134134
protected:
135-
/** Alias support for coefficient vector type. Necessary to
136-
* work around compiler bug on VC++. */
137-
using CoefficientVector = typename Superclass::CoefficientVector;
138-
using PixelType = typename Superclass::PixelType;
135+
/** Type alias support for coefficient vector type.*/
136+
using typename Superclass::CoefficientVector;
139137

140138
/** Calculates operator coefficients. */
141139
CoefficientVector

0 commit comments

Comments
 (0)