-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace READ_ELEMENT_IF with variadic template, move functions into unnamed namespace #67
Replace READ_ELEMENT_IF with variadic template, move functions into unnamed namespace #67
Conversation
The functions `tensorstoreToITKComponentType` and `itkToTensorstoreComponentType` are only used internally in their cxx file. Following C++ Core Guidelines, May 11, 2024, "Use an unnamed (anonymous) namespace for all internal/non-exported entities", http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#sf22-use-an-unnamed-anonymous-namespace-for-all-internalnon-exported-entities
3c57d75
to
4a90bbc
Compare
This line of code can just be removed, as was confirmed by Tom Birdsong at InsightSoftwareConsortium#67 (comment)
Replaced the original `READ_ELEMENT_IF` macro with a variadic template, using a C++17 fold-expression. Following C++ Core Guidelines, May 11, 2024, "Don’t use macros for program text manipulation", https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-macros
4a90bbc
to
77a2f45
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@N-Dekker nice, thanks!
const ImageIORegion & storeIORegion, | ||
void * buffer) | ||
{ | ||
return (ReadFromStoreIfTypesMatch<TPixel>(componentType, store, storeIORegion, buffer) || ...); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for merging, Matt! The most interesting part of this commit, IMhO, is the fold expression above here, which expands to something like (in pseudo code):
return Read<int8_t>() || Read<uint8_t>() || ... || Read<float>() || Read<double>();
Replaced the original `ELEMENT_WRITE` macro with a variadic template, using a C++17 fold-expression. Follow-up to pull request InsightSoftwareConsortium#67 commit 77a2f45 "STYLE: Replace READ_ELEMENT_IF with TryToReadFromStore variadic template"
Replaced the original `ELEMENT_WRITE` macro with a variadic template, using a C++17 fold-expression. Follow-up to pull request InsightSoftwareConsortium#67 commit 77a2f45 "STYLE: Replace READ_ELEMENT_IF with TryToReadFromStore variadic template"
Replaced the original `ELEMENT_WRITE` macro with a variadic template, using a C++17 fold-expression. Follow-up to pull request InsightSoftwareConsortium#67 commit 77a2f45 "STYLE: Replace READ_ELEMENT_IF with TryToReadFromStore variadic template"
Just some style improvements:
READ_ELEMENT_IF
macro with a variadic template,TryToReadFromStore
.tensorstoreToITKComponentType
anditkToTensorstoreComponentType
into an unnamed namespace