Optimize emplace(k,v) for fca containers

This commit is contained in:
Braden Ganetsky
2024-02-10 11:29:45 -06:00
parent 4e6d4ade6c
commit aff242dbaf
2 changed files with 22 additions and 2 deletions

View File

@ -14,6 +14,7 @@
#pragma once
#endif
#include <boost/unordered/detail/allocator_constructed.hpp>
#include <boost/unordered/detail/fca.hpp>
#include <boost/unordered/detail/opt_storage.hpp>
#include <boost/unordered/detail/serialize_tracked_address.hpp>
@ -104,6 +105,10 @@ namespace boost {
template <class T> no_key(T const&) {}
};
struct converting_key
{
};
namespace func {
template <class T> inline void ignore_unused_variable_warning(T const&)
{
@ -1913,6 +1918,16 @@ namespace boost {
}
}
template <typename K, typename V>
emplace_return emplace_unique(converting_key, K&& k, V&& v)
{
using alloc_cted = allocator_constructed<node_allocator_type,
typename Types::key_type>;
alloc_cted key(this->node_alloc(), std::forward<K>(k));
return emplace_unique(
key.value(), std::move(key.value()), std::forward<V>(v));
}
template <typename Key> emplace_return try_emplace_unique(Key&& k)
{
std::size_t key_hash = this->hash(k);
@ -2835,9 +2850,13 @@ namespace boost {
}
template <class Arg1, class Arg2>
static no_key extract(Arg1 const&, Arg2 const&)
static typename std::conditional<
(is_similar<Arg1, key_type>::value ||
is_complete_and_move_constructible<key_type>::value),
converting_key, no_key>::type
extract(Arg1 const&, Arg2 const&)
{
return no_key();
return {};
}
template <class Arg1, class Arg2, class Arg3, class... Args>

View File

@ -18,6 +18,7 @@ namespace boost {
typedef std::pair<K const, M> value_type;
typedef H hasher;
typedef P key_equal;
typedef K key_type;
typedef K const const_key_type;
typedef