Adds missing subscript operator to ArrayIteratorBase - #1963
Merged
Conversation
kennyweiss
requested review from
Arlie-Capps,
BradWhitlock,
bmhan12,
jcs15c,
publixsubfan,
rhornung67 and
white238
August 25, 2026 04:17
kennyweiss
force-pushed
the
bugfix/kweiss/iterator-base-subscript
branch
from
August 25, 2026 04:25
21cb31d to
07d1dbc
Compare
kennyweiss
commented
Aug 25, 2026
Comment on lines
+52
to
+55
| /// \brief Returns the value at offset \a n from the current iterator position | ||
| AXOM_HOST_DEVICE | ||
| ValueType& operator[](IndexType n) const { return m_arrayPtr->flatIndex(BaseType::m_pos + n); } | ||
|
|
Contributor
There was a problem hiding this comment.
Would it make sense to put this in IteratorBase?
Member
Author
There was a problem hiding this comment.
Good suggestion, but I don't think so since other iterators that are not random access iterators derive from IteratorBase.
E.g. ItemCollection is a forward iterator, and it's advance would give the wrong answer for operator[](-1)
See:
axom/src/axom/core/ItemCollection.hpp
Lines 207 to 214 in 97f1e49
publixsubfan
approved these changes
Aug 25, 2026
rhornung67
approved these changes
Aug 25, 2026
rhornung67
left a comment
Member
There was a problem hiding this comment.
thank you @kennyweiss for the quick fix
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.
Summary
ArrayIteratorBase, which is necessary to satisfy the random access iterator contractstd::__sift_down, called bystd::sortoperator[]without the changes toArrayIteratorBaseand are resolved with this fix