SIGN IN SIGN UP

[support] ParentIndexIterator: Add subscript and friend plus operators (#8916)

`ParentIndexIterator` declares `using iterator_category =`
`std::random_access_iterator_tag;`, but did not provide the subscript
operator (`operator[]`) or friend commutative addition (`friend
operator+(difference_type, const ParentIndexIterator&)`).

When #8912 introduced `std::sort(begin(), end())` on
`AndedConstraintSet` (which inherits from `inplace_vector`), building
`binaryen` failed on the Chromium `emscripten-releases` macOS builders
with:

```
  error: type 'wasm::inplace_vector<...>::Iterator' does not provide a subscript operator
```

This failure did not show up on Binaryen's CI because `libstdc++`
implements `std::sort` using pointer/iterator addition and dereferencing
(`*(first + child)`). In contrast, on macOS with `-stdlib=libc++`,
`libc++` implements `std::sort` (`std::__sift_down`) using
`__first[__child]` and `__first[__start]`, which requires `operator[]`.

This commit adds `decltype(auto) operator[]` and `friend operator+` to
`ParentIndexIterator` to satisfy `RandomAccessIterator` requirements.
S
Sam Clegg committed
acfdce94eae7c3ab365a659e4451dc0d7467d87f
Parent: 17ed400
Committed by GitHub <noreply@github.com> on 7/18/2026, 12:34:13 AM