use ADL lookup for erase_if instead of adding to std (gtl reported issue)

This commit is contained in:
greg7mdp
2022-06-25 14:55:26 -04:00
parent ce7710e9c3
commit 01ea8093e6
2 changed files with 19 additions and 13 deletions
+13 -7
View File
@@ -3335,6 +3335,7 @@ public:
// flat_hash_set<std::string> s;
// // Uses "abc" directly without copying it into std::string.
// s.erase("abc");
//
// --------------------------------------------------------------------
template <class K = key_type>
size_type erase(const key_arg<K>& key) {
@@ -3366,15 +3367,22 @@ public:
// ++it;
// }
// }
//
// Do not use erase APIs taking iterators when accessing the map concurrently
// --------------------------------------------------------------------
void _erase(iterator it) {
assert(it.inner_ != nullptr);
it.inner_->set_._erase(it.it_);
void _erase(iterator it, bool do_lock = true) {
Inner* inner = it.inner_;
assert(inner != nullptr);
auto& set = inner->set_;
// typename Lockable::UniqueLock m(*inner); // don't lock here
set._erase(it.it_);
}
void _erase(const_iterator cit) { _erase(cit.iter_); }
// This overload is necessary because otherwise erase<K>(const K&) would be
// a better match if non-const iterator is passed as an argument.
// Do not use erase APIs taking iterators when accessing the map concurrently
// --------------------------------------------------------------------
iterator erase(iterator it) { _erase(it++); return it; }
@@ -3387,6 +3395,7 @@ public:
// Moves elements from `src` into `this`.
// If the element already exists in `this`, it is left unmodified in `src`.
// Do not use erase APIs taking iterators when accessing the map concurrently
// --------------------------------------------------------------------
template <typename E = Eq>
void merge(parallel_hash_set<N, RefSet, Mtx_, Policy, Hash, E, Alloc>& src) { // NOLINT
@@ -4992,9 +5001,6 @@ namespace phmap {
return old_size - c.size();
}
} // priv
} // phmap
namespace std {
// ======== erase_if for phmap set containers ==================================
template <class T, class Hash, class Eq, class Alloc, class Pred>
@@ -5038,7 +5044,7 @@ namespace std {
return phmap::priv::erase_if(c, std::move(pred));
}
} // std
} // phmap
#ifdef _MSC_VER
#pragma warning(pop)