InsightSoftwareConsortium / ITK

Insight Toolkit (ITK) -- Official Repository. ITK builds on a proven, spatially-oriented architecture for processing, segmentation, and registration of scientific images in two, three, or more dimensions.
https://itk.org
Apache License 2.0
1.37k stars 660 forks source link

STYLE: Add `constexpr` to `if (Dimension ...)` statements #4719

Closed N-Dekker closed 2 weeks ago

N-Dekker commented 2 weeks ago

Made it clearer that the condition of these if statements can be evaluated at compile-time.


Cases found by the regular expression if \(\w*Dimension. Manually checked if the conditions could really be evaluated at compile-time.

N-Dekker commented 2 weeks ago

Interestingly, when having added those constexpr keywords, GCC appears to "discover" some "variable set but not used" cases, as it produces some relevant -Wunused-but-set-variable warnings that it did not produce before. At https://open.cdash.org/viewBuildError.php?type=1&buildid=9680212

itkSobelOperator.hxx: warning: variable 'center' set but not used itkJensenHavrdaCharvatTsallisPointSetMetricTest.cxx: warning: variable 'metricValues2D' set but not used itkJensenHavrdaCharvatTsallisPointSetMetricTest.cxx: warning: variable 'metricValues3D' set but not used

Addressed by the force-push that I just did.