diff --git a/absl/container/internal/raw_hash_set.h b/absl/container/internal/raw_hash_set.h index 18b1f5a4..f4919ce3 100644 --- a/absl/container/internal/raw_hash_set.h +++ b/absl/container/internal/raw_hash_set.h @@ -1921,11 +1921,12 @@ class raw_hash_set { // Erases all elements that satisfy the predicate `pred` from the container `c`. template -void EraseIf(Predicate pred, raw_hash_set* c) { +void EraseIf(Predicate& pred, raw_hash_set* c) { for (auto it = c->begin(), last = c->end(); it != last;) { - auto copy_it = it++; - if (pred(*copy_it)) { - c->erase(copy_it); + if (pred(*it)) { + c->erase(it++); + } else { + ++it; } } }