Fix TransformPhysicalPointToIndex, TransformPhysicalPointToContinuousIndex [[nodiscard]] warnings#4000
Merged
dzenanz merged 2 commits intoInsightSoftwareConsortium:masterfrom Apr 6, 2023
Conversation
When the `bool` return value of a `TransformPhysicalPointToIndex(point, index)` call can be ignored, it is preferable (for performance reasons) to call the `TransformPhysicalPointToIndex(point)` overload that just returns the index, preventing `[[nodiscard]]` compile warnings. These cases are found in Visual Studio, using the following regular expression: ` [^ ]+->TransformPhysicalPointToIndex\(.*,`
Did find code like this:
ContinuousIndexType index;
image->TransformPhysicalPointToContinuousIndex(point, index);
And replaced it by something like:
const ContinuousIndexType index =
image->template TransformPhysicalPointToContinuousIndex<ContinuousIndexValueType>(point);
When the `bool` return value is ignored, it is preferable (for performance
reasons) to call the overload that just returns the continuous index, preventing
`[[nodiscard]]` compile warnings.
These cases are found in Visual Studio, using the following regular expression:
` [^ ]+->TransformPhysicalPointToContinuousIndex\(.*,`
5f42e74 to
3f16044
Compare
dzenanz
approved these changes
Apr 6, 2023
thewtex
approved these changes
Apr 6, 2023
Member
thewtex
left a comment
There was a problem hiding this comment.
Thanks for addressing the warnings 💚
Possible follow-up noted inline.
| // In the context of the global coordinates | ||
| FeatureIndexType start; | ||
| this->GetInput()->TransformPhysicalPointToIndex(origin, start); | ||
| FeatureIndexType start = this->GetInput()->TransformPhysicalPointToIndex(origin); |
Member
There was a problem hiding this comment.
It seems many of these could be marked const now?
Contributor
Author
There was a problem hiding this comment.
Indeed, thanks Matt! Maybe for another PR? (I would like to have this one merged as soon as it's "good enough", because it fixes a few warnings at https://open.cdash.org/index.php?project=Insight)
N-Dekker
added a commit
to N-Dekker/ITK
that referenced
this pull request
Apr 7, 2023
Fixed compile errors saying: > error C2039: 'ContinuousIndexType': is not a member of 'itk::ContinuousIndex' These compile errors were introduced by pull request InsightSoftwareConsortium#4000 commit 7cda5ba "COMP: Fix TransformPhysicalPointToContinuousIndex `nodiscard` warnings"
N-Dekker
added a commit
to N-Dekker/ITK
that referenced
this pull request
Apr 7, 2023
Fixed compile errors saying: > error C2065: 'cindex': undeclared identifier These compile errors were introduced by pull request InsightSoftwareConsortium#4000 commit 7cda5ba "COMP: Fix TransformPhysicalPointToContinuousIndex `nodiscard` warnings"
N-Dekker
added a commit
to N-Dekker/ITK
that referenced
this pull request
Apr 9, 2023
Added missing `template` keywords to TransformPhysicalPointToContinuousIndex calls in Nonunit/Review tests. Addressed compile errors from Ubuntu-22.04-gcc11.2-TBB-Debug saying: > error: expected primary-expression before '>' token These compile errors were introduced by pull request InsightSoftwareConsortium#4000 commit 7cda5ba "COMP: Fix TransformPhysicalPointToContinuousIndex `nodiscard` warnings"
N-Dekker
added a commit
to N-Dekker/ITK
that referenced
this pull request
Apr 9, 2023
Added missing `template` keywords to TransformPhysicalPointToContinuousIndex calls in Nonunit/Review tests. Addressed compile errors from Ubuntu-22.04-gcc11.2-TBB-Debug saying: > error: expected primary-expression before '>' token These compile errors were introduced by pull request InsightSoftwareConsortium#4000 commit 7cda5ba "COMP: Fix TransformPhysicalPointToContinuousIndex `nodiscard` warnings"
dzenanz
pushed a commit
that referenced
this pull request
Apr 10, 2023
Added missing `template` keywords to TransformPhysicalPointToContinuousIndex calls in Nonunit/Review tests. Addressed compile errors from Ubuntu-22.04-gcc11.2-TBB-Debug saying: > error: expected primary-expression before '>' token These compile errors were introduced by pull request #4000 commit 7cda5ba "COMP: Fix TransformPhysicalPointToContinuousIndex `nodiscard` warnings"
N-Dekker
added a commit
to N-Dekker/ITK
that referenced
this pull request
Apr 17, 2023
Declared local "IndexType" variables in "Nonunit/Review" that are initialized by the result of a TransformPhysicalPointToIndex(point) call `const`. Follow-up to commit 49ece7f "COMP: Fix TransformPhysicalPointToIndex `nodiscard` warnings" Suggested by Matt McCormick at InsightSoftwareConsortium#4000 (comment)
dzenanz
pushed a commit
that referenced
this pull request
Apr 17, 2023
Declared local "IndexType" variables in "Nonunit/Review" that are initialized by the result of a TransformPhysicalPointToIndex(point) call `const`. Follow-up to commit 49ece7f "COMP: Fix TransformPhysicalPointToIndex `nodiscard` warnings" Suggested by Matt McCormick at #4000 (comment)
hjmjohnson
pushed a commit
to hjmjohnson/ITK
that referenced
this pull request
May 6, 2026
Fixed compile errors saying: > error C2039: 'ContinuousIndexType': is not a member of 'itk::ContinuousIndex' These compile errors were introduced by pull request InsightSoftwareConsortium#4000 commit 5365846 "COMP: Fix TransformPhysicalPointToContinuousIndex `nodiscard` warnings"
hjmjohnson
pushed a commit
to hjmjohnson/ITK
that referenced
this pull request
May 6, 2026
Fixed compile errors saying: > error C2065: 'cindex': undeclared identifier These compile errors were introduced by pull request InsightSoftwareConsortium#4000 commit 5365846 "COMP: Fix TransformPhysicalPointToContinuousIndex `nodiscard` warnings"
hjmjohnson
pushed a commit
to hjmjohnson/ITK
that referenced
this pull request
May 6, 2026
Added missing `template` keywords to TransformPhysicalPointToContinuousIndex calls in Nonunit/Review tests. Addressed compile errors from Ubuntu-22.04-gcc11.2-TBB-Debug saying: > error: expected primary-expression before '>' token These compile errors were introduced by pull request InsightSoftwareConsortium#4000 commit 5365846 "COMP: Fix TransformPhysicalPointToContinuousIndex `nodiscard` warnings"
hjmjohnson
pushed a commit
to hjmjohnson/ITK
that referenced
this pull request
May 6, 2026
Declared local "IndexType" variables in "Nonunit/Review" that are initialized by the result of a TransformPhysicalPointToIndex(point) call `const`. Follow-up to commit 0c7d6ae "COMP: Fix TransformPhysicalPointToIndex `nodiscard` warnings" Suggested by Matt McCormick at InsightSoftwareConsortium#4000 (comment)
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.
Replacing
TransformPhysicalPointToIndex(point, index)withindex = TransformPhysicalPointToIndex(point)appeared to be a no-brainer, while replacing theTransformPhysicalPointToContinuousIndexcalls was somewhat more challenging... but still no rocket science.