STYLE: Replace static_cast<T>(Dimension) with T{ Dimension }#5324
Merged
thewtex merged 1 commit intoInsightSoftwareConsortium:masterfrom Apr 25, 2025
Merged
Conversation
Replaced `static_cast<(\w+)>\(([A-Za-z]*Dimension)\)` with `$1{ $2 }`, using
regular expressions.
Excluded `static_cast<double>(SizeAccumulateDimension)` in
Modules/Filtering/ImageStatistics/include/itkAccumulateImageFilter.hxx, as it
is not a compile-time constant expression.
Following C++ Core Guidelines, Oct 3, 2024, "Avoid casts",
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es48-avoid-casts
dzenanz
approved these changes
Apr 24, 2025
N-Dekker
added a commit
to N-Dekker/ITK
that referenced
this pull request
May 1, 2025
Replaced `static_cast<(\w+)>\(([A-Z_][A-Z_]+)\)` with `$1{ $2 }`. According to
general C++ naming convention, these all "all caps" identifiers refer to
preprocessor macro's, so these conversions are evaluated at compile-time.
- Follow-up to pull request InsightSoftwareConsortium#5324
commit 31859d3
"STYLE: Replace `static_cast<T>(Dimension)` with `T{ Dimension }`"
N-Dekker
added a commit
to N-Dekker/ITK
that referenced
this pull request
May 1, 2025
Replaced `static_cast<(\w+)>\(([A-Z_][A-Z_]+)\)` with `$1{ $2 }`. According to
common C++ naming conventions, these all "all caps" identifiers refer to
constants, specified by preprocessor macro's, so these conversions are evaluated
at compile-time.
- Follow-up to pull request InsightSoftwareConsortium#5324
commit 31859d3
"STYLE: Replace `static_cast<T>(Dimension)` with `T{ Dimension }`"
N-Dekker
added a commit
to N-Dekker/ITK
that referenced
this pull request
May 2, 2025
Replaced `static_cast<(\w+)>\(([A-Z_][A-Z_]+)\)` with `$1{ $2 }`, using regular
expressions. According to common C++ naming conventions, these all "all caps"
identifiers refer to constants, specified by preprocessor macro's, so these
conversions are evaluated at compile-time.
Excluded replacing `static_cast<float>(RAND_MAX)` (as encountered in
"itkComplexConjugateImageAdaptorTest.cxx") because this conversion is narrowing
on some platforms. Specifically, on GCC `RAND_MAX` may be 2147483647, while it
is only 32767 on MSVC2022.
- Follow-up to pull request InsightSoftwareConsortium#5324
commit 31859d3
"STYLE: Replace `static_cast<T>(Dimension)` with `T{ Dimension }`"
dzenanz
pushed a commit
that referenced
this pull request
May 12, 2025
Replaced `static_cast<(\w+)>\(([A-Z_][A-Z_]+)\)` with `$1{ $2 }`, using regular
expressions. According to common C++ naming conventions, these all "all caps"
identifiers refer to constants, specified by preprocessor macro's, so these
conversions are evaluated at compile-time.
Excluded replacing `static_cast<float>(RAND_MAX)` (as encountered in
"itkComplexConjugateImageAdaptorTest.cxx") because this conversion is narrowing
on some platforms. Specifically, on GCC `RAND_MAX` may be 2147483647, while it
is only 32767 on MSVC2022.
- Follow-up to pull request #5324
commit 31859d3
"STYLE: Replace `static_cast<T>(Dimension)` with `T{ Dimension }`"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaced
static_cast<(\w+)>\(([A-Za-z]*Dimension)\)with$1{ $2 }, using regular expressions.Excluded
static_cast<double>(SizeAccumulateDimension), as it is not a compile-time constant expression.Following C++ Core Guidelines, "Avoid casts"
Unlike
static_cast<T>(Dimension),T{ Dimension }checks at compile-time that the dimension can be converted losslessly, for example: https://godbolt.org/z/Eoc9fhnnz