Add transparent insert_or_assign

This commit is contained in:
Christian Mazakas
2023-03-27 15:06:28 -07:00
parent 45ebc1e555
commit ce674c8007
2 changed files with 115 additions and 0 deletions
@@ -16,6 +16,7 @@
#define BOOST_UNORDERED_CONCURRENT_FLAT_MAP_HPP
#include <boost/unordered/detail/foa/concurrent_table.hpp>
#include <boost/unordered/detail/type_traits.hpp>
#include <boost/container_hash/hash.hpp>
#include <boost/core/allocator_access.hpp>
@@ -163,6 +164,17 @@ namespace boost {
std::forward<M>(obj));
}
template <class K, class M>
typename std::enable_if<
detail::are_transparent<K, hasher, key_equal>::value, bool>::type
insert_or_assign(K&& k, M&& obj)
{
return table_.try_emplace_or_visit(
std::forward<K>(k),
[&](value_type& m) { m.second = std::forward<M>(obj); },
std::forward<M>(obj));
}
/// Hash Policy
///
void rehash(size_type n) { table_.rehash(n); }