diff options
author | Abseil Team <absl-team@google.com> | 2021-11-30 14:02:51 -0800 |
---|---|---|
committer | Andy Getz <durandal@google.com> | 2021-12-01 13:14:03 -0500 |
commit | cad715dbf375a336fcb0b2b0ef57fc2b7a1b0b4b (patch) | |
tree | 43c6ab9076b6d72f1138004a4d972db785eda143 /absl/container/btree_map.h | |
parent | 3e1983c5c07eb8a43ad030e770cbae023a470a04 (diff) |
Export of internal Abseil changes
--
e2a571b818faaec4185426a8cf71fd2970674423 by Matt Kulukundis <kfm@google.com>:
Fix missed use of old RTTI macro
PiperOrigin-RevId: 413239579
--
e3c15a3fe0a4e44d6e08d69ad912b2245a403bd6 by Derek Mauro <dmauro@google.com>:
Makes erase_if return the number of erased elements for compatibility
with C++20
https://en.cppreference.com/w/cpp/container/unordered_map/erase_if
This may technically be an API break, but no actual breaks were found
in Google code. Fixes to open source code should be trivial.
Closes #1065
PiperOrigin-RevId: 413204392
--
c1fb1ddbc2def3f3d177e5b80b9934bdbb7b16fc by Matt Kulukundis <kfm@google.com>:
Consolidate to a single HAS_RTTI macro
PiperOrigin-RevId: 413169336
GitOrigin-RevId: e2a571b818faaec4185426a8cf71fd2970674423
Change-Id: I74b78ebd5fc172e3f5fcbd13a58cf53f7b250ae9
Diffstat (limited to 'absl/container/btree_map.h')
-rw-r--r-- | absl/container/btree_map.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/absl/container/btree_map.h b/absl/container/btree_map.h index 4eafe062..797b949f 100644 --- a/absl/container/btree_map.h +++ b/absl/container/btree_map.h @@ -478,8 +478,11 @@ void swap(btree_map<K, V, C, A> &x, btree_map<K, V, C, A> &y) { // absl::erase_if(absl::btree_map<>, Pred) // // Erases all elements that satisfy the predicate pred from the container. +// Returns the number of erased elements. template <typename K, typename V, typename C, typename A, typename Pred> -void erase_if(btree_map<K, V, C, A> &map, Pred pred) { +typename btree_map<K, V, C, A>::size_type erase_if( + btree_map<K, V, C, A> &map, Pred pred) { + const auto initial_size = map.size(); for (auto it = map.begin(); it != map.end();) { if (pred(*it)) { it = map.erase(it); @@ -487,6 +490,7 @@ void erase_if(btree_map<K, V, C, A> &map, Pred pred) { ++it; } } + return initial_size - map.size(); } // absl::btree_multimap @@ -809,8 +813,11 @@ void swap(btree_multimap<K, V, C, A> &x, btree_multimap<K, V, C, A> &y) { // absl::erase_if(absl::btree_multimap<>, Pred) // // Erases all elements that satisfy the predicate pred from the container. +// Returns the number of erased elements. template <typename K, typename V, typename C, typename A, typename Pred> -void erase_if(btree_multimap<K, V, C, A> &map, Pred pred) { +typename btree_multimap<K, V, C, A>::size_type erase_if( + btree_multimap<K, V, C, A> &map, Pred pred) { + const auto initial_size = map.size(); for (auto it = map.begin(); it != map.end();) { if (pred(*it)) { it = map.erase(it); @@ -818,6 +825,7 @@ void erase_if(btree_multimap<K, V, C, A> &map, Pred pred) { ++it; } } + return initial_size - map.size(); } namespace container_internal { |