Skip to content

ENH: Add ITK_NO_DISCARD(message) macro to Image "Transform" members#4007

Merged
dzenanz merged 1 commit intoInsightSoftwareConsortium:masterfrom
dzenanz:itkNoDiscard
Apr 12, 2023
Merged

ENH: Add ITK_NO_DISCARD(message) macro to Image "Transform" members#4007
dzenanz merged 1 commit intoInsightSoftwareConsortium:masterfrom
dzenanz:itkNoDiscard

Conversation

@dzenanz
Copy link
Copy Markdown
Member

@dzenanz dzenanz commented Apr 11, 2023

The new macro is applied only to the overloads which take two arguments and return the bool. This is the only scenario where it made sense to ignore the return value.

PR Checklist

@github-actions github-actions Bot added type:Enhancement Improvement of existing methods or implementation area:Core Issues affecting the Core module labels Apr 11, 2023
@dzenanz dzenanz marked this pull request as ready for review April 11, 2023 20:13
Comment thread Modules/Core/Common/include/itkMacro.h
Comment on lines +468 to +469
ITK_NO_DISCARD(Call the overload which has the point as the only parameter and returns the index)
bool TransformPhysicalPointToIndex(const Point<TCoordRep, VImageDimension> & point, IndexType & index) const
Copy link
Copy Markdown
Contributor

@N-Dekker N-Dekker Apr 11, 2023

Choose a reason for hiding this comment

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

Please consider to leave the unconditional [[nodiscard]] (even for legacy-only) here. For TransformPhysicalPointToIndex, it's really a no-brainer to replace it with the other overload. (It does not have the template difficulty that TransformPhysicalPointToContinuousIndex has.)

Look at commit 49ece7f it is really straightforward. No extra template argument needed. The faster TransformPhysicalPointToIndex(point) overload has been there already with ITK 5.0.0

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Even if replacement is easy, it requires code changes. The legacy flag's purpose is to allow this to be made gradually.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I agree with @dzenanz Even these easy changes can be quite disruptive for end-users.

Comment thread Modules/Core/Common/include/itkImageBase.h
The new macro is applied only to the overloads
which take two arguments and return the bool.
This is the only scenario where it made sense
to ignore the return value.
Copy link
Copy Markdown
Member

@hjmjohnson hjmjohnson left a comment

Choose a reason for hiding this comment

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

@dzenanz Thanks!

Copy link
Copy Markdown
Contributor

@N-Dekker N-Dekker left a comment

Choose a reason for hiding this comment

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

Thanks for including most of my suggestions 😃

@dzenanz dzenanz merged commit bc75d43 into InsightSoftwareConsortium:master Apr 12, 2023
@dzenanz dzenanz deleted the itkNoDiscard branch April 12, 2023 17:11
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 type:Enhancement Improvement of existing methods or implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants