[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:17 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
+    map.insert(2);
+
+    auto erase = map.equal_range(2);
+    map.erase(erase.first, erase.second);
+    auto test = map.equal_range(1);
+    assert(test.first != test.second);
----------------
ldionne wrote:

Can we instead iterate through the map after erasing and confirm that each element/bucket is the way we'd expect?

https://github.com/llvm/llvm-project/pull/162850


More information about the libcxx-commits mailing list