Commit 52e905e7 by Abseil Team Committed by Copybara-Service

Improve documentation on erase.

PiperOrigin-RevId: 460509198
Change-Id: I6d85443cc3f568230f3a3d46b63358129654ddb9
parent 90099691
......@@ -228,9 +228,11 @@ class flat_hash_map : public absl::container_internal::raw_hash_map<
// NOTE: returning `void` in this case is different than that of STL
// containers in general and `std::unordered_map` in particular (which
// return an iterator to the element following the erased element). If that
// iterator is needed, simply post increment the iterator:
// iterator is needed, copy the iterator before erasing:
//
// map.erase(it++);
// // `erase()` will invalidate `it`, so advance `it` first.
// auto copy_it = it++;
// m.erase(copy_it);
//
// iterator erase(const_iterator first, const_iterator last):
//
......
......@@ -220,9 +220,11 @@ class flat_hash_set
// NOTE: returning `void` in this case is different than that of STL
// containers in general and `std::unordered_set` in particular (which
// return an iterator to the element following the erased element). If that
// iterator is needed, simply post increment the iterator:
// iterator is needed, copy the iterator before erasing:
//
// set.erase(it++);
// // `erase()` will invalidate `it`, so advance `it` first.
// auto copy_it = it++;
// set.erase(copy_it);
//
// iterator erase(const_iterator first, const_iterator last):
//
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment