diff options
author | Thomas Lively <tlively@google.com> | 2023-03-10 14:21:06 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-10 12:21:06 -0800 |
commit | f568b250e09d5c69cc855f1b9affc8346d736a73 (patch) | |
tree | 117d74deac7479eae530c4fc06db0f06f823593a /src | |
parent | a3cc3a514a754cf8d505806055194622606893f1 (diff) | |
download | binaryen-f568b250e09d5c69cc855f1b9affc8346d736a73.tar.gz binaryen-f568b250e09d5c69cc855f1b9affc8346d736a73.tar.bz2 binaryen-f568b250e09d5c69cc855f1b9affc8346d736a73.zip |
[NFC] Add missing parts of `ChildIterator` (#5566)
The missing associated types will become necessary if we ever use these
iterators in a nontrivial manner. Make the parent reference into a pointer so
that the copy constructor and assignment operator are not implicitly deleted.
Diffstat (limited to 'src')
-rw-r--r-- | src/ir/iteration.h | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/ir/iteration.h b/src/ir/iteration.h index 8da03a555..3b2c5ce28 100644 --- a/src/ir/iteration.h +++ b/src/ir/iteration.h @@ -44,13 +44,19 @@ template<class Specific> class AbstractChildIterator { using Self = AbstractChildIterator<Specific>; struct Iterator { - const Self& parent; + using difference_type = std::ptrdiff_t; + using value_type = Expression*; + using pointer = Expression**; + using reference = Expression*&; + using iterator_category = std::forward_iterator_tag; + + const Self* parent; Index index; - Iterator(const Self& parent, Index index) : parent(parent), index(index) {} + Iterator(const Self* parent, Index index) : parent(parent), index(index) {} bool operator!=(const Iterator& other) const { - return index != other.index || &parent != &(other.parent); + return index != other.index || parent != other.parent; } bool operator==(const Iterator& other) const { return !(*this != other); } @@ -58,7 +64,7 @@ template<class Specific> class AbstractChildIterator { void operator++() { index++; } Expression*& operator*() { - return *parent.children[parent.mapIndex(index)]; + return *parent->children[parent->mapIndex(index)]; } }; @@ -110,8 +116,8 @@ public: #include "wasm-delegations-fields.def" } - Iterator begin() const { return Iterator(*this, 0); } - Iterator end() const { return Iterator(*this, children.size()); } + Iterator begin() const { return Iterator(this, 0); } + Iterator end() const { return Iterator(this, children.size()); } void addChild(Expression* parent, Expression** child) { children.push_back(child); |