[libcxx-commits] [libcxx] Reapply "[libc++] Optimize __hash_table::erase(iterator, iterator)" (PR #162850)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Oct 15 07:19:18 PDT 2025
================
@@ -47,6 +47,18 @@ int main(int, char**) {
assert(c.size() == 0);
assert(k == c.end());
}
+ {
+ std::unordered_multiset<size_t> map;
+ map.rehash(3);
+ map.insert(1);
+ map.insert(5); // 5 % 3 == 2, so 5 and 2 are in the same bucket
----------------
ldionne wrote:
At the end of the day, the assumption is that 5 and 2 are in the same bucket. That can be verified with `assert(map.bucket(2) == map.bucket(5))`. Maybe libc++ specific.
Or, as you just suggested, insert `2` and then `2 + bucket_count` -- that's a guaranteed collision (you'd still want to `assert` it though).
https://github.com/llvm/llvm-project/pull/162850
More information about the libcxx-commits
mailing list