From 23a1a79603d5d102b82558c7822eaa1bbed16fd2 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Mon, 25 Apr 2022 13:20:27 -0700 Subject: SmallSet: Mark iterator parent as const (#4613) We already assume the parent does not change, binaryen/src/support/small_set.h Lines 202 to 208 in 94d77ef // std::set allows changes while iterating. For us here, though, it would // be nontrivial to support that given we have two iterators that we // generalize over (switching "in the middle" would not be easy or fast), // so error on that. if (usingFixed != other.usingFixed) { Fatal() << "SmallSet does not support changes while iterating"; } This also marks the parent as const to reflect that. This fixed a weird C++ compilation error I had when working on something unrelated, but seems worth landing independently. --- src/support/small_set.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/support/small_set.h') diff --git a/src/support/small_set.h b/src/support/small_set.h index 9ee0f0403..f8725ec9d 100644 --- a/src/support/small_set.h +++ b/src/support/small_set.h @@ -165,7 +165,7 @@ public: using pointer = const value_type*; using reference = const value_type&; - Parent* parent; + const Parent* parent; using Iterator = IteratorBase; @@ -176,7 +176,7 @@ public: size_t fixedIndex; FlexibleIterator flexibleIterator; - IteratorBase(Parent* parent) + IteratorBase(const Parent* parent) : parent(parent), usingFixed(parent->usingFixed()) {} void setBegin() { -- cgit v1.2.3