Skip to content

Commit 23a1a79

Browse files
authored
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.
1 parent 94d77ef commit 23a1a79

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/support/small_set.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ template<typename T, size_t N, typename FlexibleSet> class SmallSetBase {
165165
using pointer = const value_type*;
166166
using reference = const value_type&;
167167

168-
Parent* parent;
168+
const Parent* parent;
169169

170170
using Iterator = IteratorBase<Parent, FlexibleIterator>;
171171

@@ -176,7 +176,7 @@ template<typename T, size_t N, typename FlexibleSet> class SmallSetBase {
176176
size_t fixedIndex;
177177
FlexibleIterator flexibleIterator;
178178

179-
IteratorBase(Parent* parent)
179+
IteratorBase(const Parent* parent)
180180
: parent(parent), usingFixed(parent->usingFixed()) {}
181181

182182
void setBegin() {

0 commit comments

Comments
 (0)