ENH: Replace PrintSelf NumericTraits-cast boilerplate with itk::print_helper::PrintNumericTrait helper (supersedes #3909)#6234
Merged
hjmjohnson merged 2 commits intoMay 10, 2026
Conversation
Contributor
|
Too many files changed for review. ( |
dc9dbc9 to
6c892db
Compare
dzenanz
reviewed
May 8, 2026
Member
dzenanz
left a comment
There was a problem hiding this comment.
Mostly looks good on a glance.
dzenanz
reviewed
May 8, 2026
dzenanz
reviewed
May 8, 2026
Non-macro replacement for the recurring PrintSelf boilerplate
os << indent << "Name: "
<< static_cast<typename NumericTraits<T>::PrintType>(this->m_Name)
<< std::endl;
Explicit os/indent parameters (no implicit capture). constexpr
dispatch elides the cast when PrintType == T. Supersedes InsightSoftwareConsortium#3909.
Co-Authored-By: Jon Haitz Legarreta Gorroño <jhlegarreta@users.noreply.github.com>
9f9fee6 to
0074c8e
Compare
jhlegarreta
reviewed
May 10, 2026
Convert 513 PrintSelf call sites across 221 files in Modules/ to itk::print_helper::PrintNumericTrait. Handles 1/2-line forms, typename and itk:: variants, member and method-call expressions. Chained-statement form intentionally untouched (1 leftover at Modules/Filtering/ImageFusion/include/itkLabelOverlayImageFilter.hxx:103). No observable runtime change. Co-Authored-By: Jon Haitz Legarreta Gorroño <jhlegarreta@users.noreply.github.com>
0074c8e to
17a76eb
Compare
jhlegarreta
approved these changes
May 10, 2026
Member
jhlegarreta
left a comment
There was a problem hiding this comment.
Thanks for your relentless efforts, Hans.
2 tasks
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.
Replace the
os << indent << "Name: " << static_cast<typename NumericTraits<T>::PrintType>(this->m_Name) << std::endl;boilerplate in 513PrintSelfoverrides across 221 files withitk::print_helper::PrintNumericTrait(os, indent, "Name", this->m_Name);. Supersedes #3909 (which proposed a macro).How #3909's review concerns are resolved
itk::print_helper; no macroosandindentout as explicit params<<co-locationitkPrintHelper.hif constexpr (std::is_same_v<T, NumericTraits<T>::PrintType>)skips itstd::complex<T>(PrintType = Self)Commits
ENH:Additk::print_helper::PrintNumericTraithelper (helper + 6 tests for double / int / unsigned char / signed char /complex<double>/ indented output)ENH:AdoptPrintNumericTraithelper toolkit-wide (mechanical regex conversion; 1 chained-statement leftover left for follow-up —Modules/Filtering/ImageFusion/include/itkLabelOverlayImageFilter.hxx:103)Co-authored with @jhlegarreta.
Local validation
pre-commit run --all-files: cleanbuild-pythonctest -R PrintHelper: 17/17 (incl. 6 newPrintNumericTraitcases)ImageRegistrationMethodv4|MeanSquares|FastMarching|ImageStatistics|MultiResolution): 63/63Closes #3909.