-
-
Notifications
You must be signed in to change notification settings - Fork 668
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
Make the index type of VectorContainer itk::SizeValueType
by default
#4856
Make the index type of VectorContainer itk::SizeValueType
by default
#4856
Conversation
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.
Mostly looks good.
9269414
to
114e2b5
Compare
namespace ClassTemplate | ||
{ |
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.
This pull request places the original class template VectorContainer
in a nested namespace, itk::ClassTemplate
, so that it will still be available to users who really need to access the original class. Usually, users may just use itk::VectorContainer
(as before), which will then be an alias to itk::ClassTemplate::VectorContainer
.
This approach is a bit of a workaround. Maybe we can eventually just define itk::VectorContainer<TElement>
as a template class, without the TElementIdentifier
parameter. But that would be a breaking change. 🤷
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.
I think we should use itk::detail::
here instead of creating a new namespace.
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 the suggestion @thewtex. Addressed by my latest force-push, please check!
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 awesome!!
Naming comment inline.
*/ | ||
template <typename T1, typename T2 = void> | ||
using VectorContainer = ClassTemplate::VectorContainer<std::conditional_t<std::is_void_v<T2>, SizeValueType, T1>, | ||
std::conditional_t<std::is_void_v<T2>, T1, T2>>; |
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.
Cool!
namespace ClassTemplate | ||
{ |
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.
I think we should use itk::detail::
here instead of creating a new namespace.
By default, assume `ElementIdentifier = SizeValueType`, for an `itk::VectorContainer<ElementType>`. Conceptually like: template <typename TElementIdentifier = SizeValueType, typename TElement> class VectorContainer; Implemented by moving the old `VectorContainer` definition into the `itk::detail` namespace, and introducing a new `itk::VectorContainer<T1, T2>` alias template.
The index type (`ElementIdentifier`) of `itk::VectorContainer` is already `itk::SizeValueType` by default.
Also removed an `IdentifierType` alias. The index type (`ElementIdentifier`) of `itk::VectorContainer` is already `itk::SizeValueType` by default, and `itk::IdentifierType` is just an alias of `itk::SizeValueType`.
114e2b5
to
edae0bc
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.
Excellent!! ✨
Following pull request InsightSoftwareConsortium#4856 commit edae0bc "STYLE: Remove IdentifierType template argument from VectorContainer uses"
Simplified the tests by just using the default element identifier type, which is `itk::SizeValueType`. Following pull request InsightSoftwareConsortium#4856 commit edae0bc "STYLE: Remove IdentifierType template argument from VectorContainer uses"
Following pull request InsightSoftwareConsortium#4856 commit edae0bc "STYLE: Remove IdentifierType template argument from VectorContainer uses"
For most use cases, it appears that the index type of
itk::VectorContainer
should just beitk::SizeValueType
(oritk::IdentifierType
, but that's just an alias ofitk::SizeValueType
).This pull request allows users to write
itk::VectorContainer<ElementType>
as a shorthand foritk::VectorContainer<itk::SizeValueType, ElementType>
.