Skip to content
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

Conversation

N-Dekker
Copy link
Contributor

For most use cases, it appears that the index type of itk::VectorContainer should just be itk::SizeValueType (or itk::IdentifierType, but that's just an alias of itk::SizeValueType).

This pull request allows users to write itk::VectorContainer<ElementType> as a shorthand for itk::VectorContainer<itk::SizeValueType, ElementType>.

@github-actions github-actions bot added type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct area:Core Issues affecting the Core module area:Filtering Issues affecting the Filtering module area:IO Issues affecting the IO module area:Registration Issues affecting the Registration module labels Sep 20, 2024
Copy link
Member

@dzenanz dzenanz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly looks good.

@N-Dekker N-Dekker force-pushed the VectorContainer-default-index branch 2 times, most recently from 9269414 to 114e2b5 Compare September 27, 2024 11:59
Comment on lines 30 to 31
namespace ClassTemplate
{
Copy link
Contributor Author

@N-Dekker N-Dekker Sep 27, 2024

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. 🤷

Copy link
Member

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.

Copy link
Contributor Author

@N-Dekker N-Dekker Oct 3, 2024

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!

@N-Dekker N-Dekker marked this pull request as ready for review September 27, 2024 15:59
Copy link
Member

@thewtex thewtex left a 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>>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool!

Comment on lines 30 to 31
namespace ClassTemplate
{
Copy link
Member

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`.
@N-Dekker N-Dekker force-pushed the VectorContainer-default-index branch from 114e2b5 to edae0bc Compare October 3, 2024 08:52
@N-Dekker N-Dekker requested a review from thewtex October 3, 2024 08:55
Copy link
Member

@thewtex thewtex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent!! ✨

@thewtex thewtex merged commit ed46040 into InsightSoftwareConsortium:master Oct 7, 2024
13 checks passed
N-Dekker added a commit to N-Dekker/ITK that referenced this pull request Oct 10, 2024
Following pull request InsightSoftwareConsortium#4856
commit edae0bc
"STYLE: Remove IdentifierType template argument from VectorContainer uses"
N-Dekker added a commit to N-Dekker/ITK that referenced this pull request Oct 10, 2024
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"
N-Dekker added a commit to N-Dekker/ITK that referenced this pull request Oct 10, 2024
Following pull request InsightSoftwareConsortium#4856
commit edae0bc
"STYLE: Remove IdentifierType template argument from VectorContainer uses"
dzenanz pushed a commit that referenced this pull request Oct 17, 2024
Following pull request #4856
commit edae0bc
"STYLE: Remove IdentifierType template argument from VectorContainer uses"
dzenanz pushed a commit that referenced this pull request Oct 17, 2024
Simplified the tests by just using the default element identifier type, which is
`itk::SizeValueType`.

Following pull request #4856
commit edae0bc
"STYLE: Remove IdentifierType template argument from VectorContainer uses"
dzenanz pushed a commit that referenced this pull request Oct 17, 2024
Following pull request #4856
commit edae0bc
"STYLE: Remove IdentifierType template argument from VectorContainer uses"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:Core Issues affecting the Core module area:Filtering Issues affecting the Filtering module area:IO Issues affecting the IO module area:Registration Issues affecting the Registration module type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants