Skip to content

Commit 0fa82fb

Browse files
authored
Merge pull request #5671 from N-Dekker/GetLength-constexpr
STYLE: Make `NumericTraits::GetLength` constexpr whenever possible
2 parents 5032829 + d720117 commit 0fa82fb

9 files changed

+18
-18
lines changed

Modules/Core/Common/include/itkNumericTraits.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,14 +198,14 @@ class NumericTraits : public std::numeric_limits<T>
198198
* VariableLengthVector will provide a different implementation
199199
* where a vector of the correct size is built.
200200
*/
201-
static unsigned int
201+
static constexpr unsigned int
202202
GetLength(const T &)
203203
{
204204
return GetLength();
205205
}
206206

207207
/** Return the length of the scalar: 1. Array types can return a different value */
208-
static unsigned int
208+
static constexpr unsigned int
209209
GetLength()
210210
{
211211
return 1;

Modules/Core/Common/include/itkNumericTraitsCovariantVectorPixel.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,14 +161,14 @@ class NumericTraits<CovariantVector<T, D>>
161161
}
162162

163163
/** Return the length of the vector. */
164-
static unsigned int
164+
static constexpr unsigned int
165165
GetLength(const CovariantVector<T, D> &)
166166
{
167167
return D;
168168
}
169169

170170
/** Return the length of the vector. */
171-
static unsigned int
171+
static constexpr unsigned int
172172
GetLength()
173173
{
174174
return D;

Modules/Core/Common/include/itkNumericTraitsDiffusionTensor3DPixel.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,14 @@ class NumericTraits<DiffusionTensor3D<T>>
163163
}
164164

165165
/** Return the size of the tensor. Always returns 6. */
166-
static unsigned int
166+
static constexpr unsigned int
167167
GetLength(const DiffusionTensor3D<T> &)
168168
{
169169
return 6;
170170
}
171171

172172
/** Return the size of the tensor. Always returns 6. */
173-
static unsigned int
173+
static constexpr unsigned int
174174
GetLength()
175175
{
176176
return 6;

Modules/Core/Common/include/itkNumericTraitsFixedArrayPixel.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,14 @@ class NumericTraits<FixedArray<T, D>>
157157
}
158158

159159
/** Return the length of the array. */
160-
static unsigned int
160+
static constexpr unsigned int
161161
GetLength(const FixedArray<T, D> &)
162162
{
163163
return D;
164164
}
165165

166166
/** Return the length of the array. */
167-
static unsigned int
167+
static constexpr unsigned int
168168
GetLength()
169169
{
170170
return D;

Modules/Core/Common/include/itkNumericTraitsPointPixel.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,14 @@ class NumericTraits<Point<T, D>>
148148
}
149149

150150
/** Return the dimensionality of the point. */
151-
static unsigned int
151+
static constexpr unsigned int
152152
GetLength(const Point<T, D> &)
153153
{
154154
return D;
155155
}
156156

157157
/** Return the dimensionality of the point. */
158-
static unsigned int
158+
static constexpr unsigned int
159159
GetLength()
160160
{
161161
return D;

Modules/Core/Common/include/itkNumericTraitsRGBAPixel.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,14 @@ class NumericTraits<RGBAPixel<T>>
188188
}
189189

190190
/** Return the dimensionality of the pixel. Always returns 4. */
191-
static unsigned int
191+
static constexpr unsigned int
192192
GetLength(const RGBAPixel<T> &)
193193
{
194194
return 4;
195195
}
196196

197197
/** Return the dimensionality of the pixel. Always returns 4. */
198-
static unsigned int
198+
static constexpr unsigned int
199199
GetLength()
200200
{
201201
return 4;

Modules/Core/Common/include/itkNumericTraitsRGBPixel.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,14 @@ class NumericTraits<RGBPixel<T>>
188188
}
189189

190190
/** Return the dimensionality of the pixel. Always returns 3. */
191-
static unsigned int
191+
static constexpr unsigned int
192192
GetLength(const RGBPixel<T> &)
193193
{
194194
return 3;
195195
}
196196

197197
/** Return the dimensionality of the pixel. Always returns 3. */
198-
static unsigned int
198+
static constexpr unsigned int
199199
GetLength()
200200
{
201201
return 3;

Modules/Core/Common/include/itkNumericTraitsTensorPixel.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,14 @@ class NumericTraits<SymmetricSecondRankTensor<T, D>>
163163
}
164164

165165
/** Return the size of the underlying FixedArray. */
166-
static unsigned int
166+
static constexpr unsigned int
167167
GetLength(const SymmetricSecondRankTensor<T, D> &)
168168
{
169169
return GetLength();
170170
}
171171

172172
/** Return the size of the underlying FixedArray. */
173-
static unsigned int
173+
static constexpr unsigned int
174174
GetLength()
175175
{
176176
return D * (D + 1) / 2;

Modules/Core/Common/include/itkNumericTraitsVectorPixel.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,14 @@ class NumericTraits<Vector<T, D>>
203203
}
204204

205205
/** Return the size of the vector. */
206-
static unsigned int
206+
static constexpr unsigned int
207207
GetLength(const Vector<T, D> &)
208208
{
209209
return D;
210210
}
211211

212212
/** Return the size of the vector. */
213-
static unsigned int
213+
static constexpr unsigned int
214214
GetLength()
215215
{
216216
return D;

0 commit comments

Comments
 (0)