ENH: Add constexpr overloads for itk::Math::abs#5797
Open
hjmjohnson wants to merge 1 commit intomainfrom
Open
Conversation
4fcc6d0 to
0d1a52b
Compare
eb506bd to
60ab154
Compare
N-Dekker
reviewed
Feb 13, 2026
N-Dekker
reviewed
Feb 13, 2026
a19ef23 to
d71da7d
Compare
N-Dekker
reviewed
Feb 13, 2026
d71da7d to
236f95f
Compare
dzenanz
reviewed
Feb 13, 2026
Include bool, integral, and floating-point support Refactored `itk::Math::abs` with constexpr for bool, integer and floating point types. Conditionally use `std::abs` within itk:: when constexpr is available (i.e. c++23 and greater), or revert to custom constexpr code for c++17-c++23. Maintain backward compatibility with pre-ITKv6.0 computations while enabling explicit `std::abs` usage for modern standards. Signed types are promoted to unsigned return types for integers. Remove "using std::abs" which was polluting the itk namespace with hard to interpret intent, provide explicit support for all itk types with the itk::safe_abs(). itk::safe_abs is constexpr compatible for bool, floating, and integer types.
83c0d97 to
3cc3f4a
Compare
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.
Include integral and floating-point support
Refactored
itk::Math::absc++ constexpr,supporting both integral and floating-point types. Improved compile-time
evaluation with
constexpr. Enhanced test coverage foritk::Math::abs.PR Checklist