Commit acfdce9
authored
[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.1 parent 17ed400 commit acfdce9
2 files changed
Lines changed: 21 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
28 | | - | |
| 27 | + | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
99 | 103 | | |
100 | 104 | | |
101 | 105 | | |
| |||
107 | 111 | | |
108 | 112 | | |
109 | 113 | | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
110 | 117 | | |
111 | 118 | | |
112 | 119 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
0 commit comments