Skip to content

Commit e3cf5b3

Browse files
Abseil Teamcopybara-github
authored andcommitted
Add comment on how to get next element after using erase.
PiperOrigin-RevId: 696930388 Change-Id: I7bd45c8a80458a84826a85392106d18833901154
1 parent 8f739d1 commit e3cf5b3

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

absl/container/node_hash_map.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,13 @@ class ABSL_ATTRIBUTE_OWNER node_hash_map
236236
// Erases the element at `position` of the `node_hash_map`, returning
237237
// `void`.
238238
//
239-
// NOTE: this return behavior is different than that of STL containers in
240-
// general and `std::unordered_map` in particular.
239+
// NOTE: Returning `void` in this case is different than that of STL
240+
// containers in general and `std::unordered_map` in particular (which
241+
// return an iterator to the element following the erased element). If that
242+
// iterator is needed, simply post increment the iterator:
243+
//
244+
// map.erase(it++);
245+
//
241246
//
242247
// iterator erase(const_iterator first, const_iterator last):
243248
//

absl/container/node_hash_set.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,13 @@ class ABSL_ATTRIBUTE_OWNER node_hash_set
230230
// Erases the element at `position` of the `node_hash_set`, returning
231231
// `void`.
232232
//
233-
// NOTE: this return behavior is different than that of STL containers in
234-
// general and `std::unordered_set` in particular.
233+
// NOTE: Returning `void` in this case is different than that of STL
234+
// containers in general and `std::unordered_map` in particular (which
235+
// return an iterator to the element following the erased element). If that
236+
// iterator is needed, simply post increment the iterator:
237+
//
238+
// map.erase(it++);
239+
//
235240
//
236241
// iterator erase(const_iterator first, const_iterator last):
237242
//

0 commit comments

Comments
 (0)