summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Lively <tlively@google.com>2023-03-10 16:25:02 -0600
committerGitHub <noreply@github.com>2023-03-10 14:25:02 -0800
commit5c408e22badb4b611155fd3a3d07000538e47341 (patch)
treeb9c6fd5d98d112b239e80ba38a4514e1f04d1233 /src
parenta389185799e39368856bc8b6a3f10eb713fc0643 (diff)
downloadbinaryen-5c408e22badb4b611155fd3a3d07000538e47341.tar.gz
binaryen-5c408e22badb4b611155fd3a3d07000538e47341.tar.bz2
binaryen-5c408e22badb4b611155fd3a3d07000538e47341.zip
Fix ambiguous operators under C++20 (#5567)
When resolving `operator!=`, C++20 also considers `operator==` implementations when the types on `operator!=` do not match exactly. This caused the modified code to have no most-specific overload to choose, resulting in an error. This is actually a bug in the language that is being fixed, but there exist compilers without the fix applied. Work around the problem by updating the types in the declaration of `operator==` and `operator!=` to be more exact. This is a copy of #5029 with formatting fixes.
Diffstat (limited to 'src')
-rw-r--r--src/support/parent_index_iterator.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/support/parent_index_iterator.h b/src/support/parent_index_iterator.h
index 1375ab204..e19aacfdc 100644
--- a/src/support/parent_index_iterator.h
+++ b/src/support/parent_index_iterator.h
@@ -49,10 +49,12 @@ template<typename Parent, typename Iterator> struct ParentIndexIterator {
Iterator& self() { return *static_cast<Iterator*>(this); }
- bool operator==(const Iterator& other) const {
+ bool operator==(const ParentIndexIterator& other) const {
return index == other.index && parent == other.parent;
}
- bool operator!=(const Iterator& other) const { return !(*this == other); }
+ bool operator!=(const ParentIndexIterator& other) const {
+ return !(*this == other);
+ }
Iterator& operator++() {
++index;
return self();