summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2022-10-31 12:31:26 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2022-10-31 12:32:21 -0700
commitd819278ab70ee5e59fa91d76a66abeaa106b95c9 (patch)
tree09ef52f4ed059a241ad73bc990718f8c7f4a8aee
parentea882fb76637f00e9a547ce1c6c42cd90a7f955b (diff)
Add a warning about extract invalidating iterators (not just the iterator of the element being extracted).
PiperOrigin-RevId: 485120182 Change-Id: Ic54d538721678bed0a748dacbf33c319e62b93b8
-rw-r--r--absl/container/btree_map.h7
-rw-r--r--absl/container/btree_set.h5
2 files changed, 7 insertions, 5 deletions
diff --git a/absl/container/btree_map.h b/absl/container/btree_map.h
index 479db8b7..819a925f 100644
--- a/absl/container/btree_map.h
+++ b/absl/container/btree_map.h
@@ -44,8 +44,8 @@
// an issue if insertion and deletion operations are interleaved with the use of
// more than one iterator, pointer, or reference simultaneously. For this
// reason, `insert()` and `erase()` return a valid iterator at the current
-// position. Another important difference is that key-types must be
-// copy-constructible.
+// position (and `extract()` cannot be used in this way). Another important
+// difference is that key-types must be copy-constructible.
//
// Another API difference is that btree iterators can be subtracted, and this
// is faster than using std::distance.
@@ -325,7 +325,8 @@ class btree_map
// btree_map::extract()
//
// Extracts the indicated element, erasing it in the process, and returns it
- // as a C++17-compatible node handle. Overloads are listed below.
+ // as a C++17-compatible node handle. Any references, pointers, or iterators
+ // are invalidated. Overloads are listed below.
//
// node_type extract(const_iterator position):
//
diff --git a/absl/container/btree_set.h b/absl/container/btree_set.h
index bbff65d1..d93bdbf6 100644
--- a/absl/container/btree_set.h
+++ b/absl/container/btree_set.h
@@ -44,7 +44,7 @@
// an issue if insertion and deletion operations are interleaved with the use of
// more than one iterator, pointer, or reference simultaneously. For this
// reason, `insert()` and `erase()` return a valid iterator at the current
-// position.
+// position (and `extract()` cannot be used in this way).
//
// Another API difference is that btree iterators can be subtracted, and this
// is faster than using std::distance.
@@ -272,7 +272,8 @@ class btree_set
// btree_set::extract()
//
// Extracts the indicated element, erasing it in the process, and returns it
- // as a C++17-compatible node handle. Overloads are listed below.
+ // as a C++17-compatible node handle. Any references, pointers, or iterators
+ // are invalidated. Overloads are listed below.
//
// node_type extract(const_iterator position):
//