forked from boostorg/unordered
Optimize emplace(k,v) for fca containers
This commit is contained in:
@ -14,6 +14,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <boost/unordered/detail/allocator_constructed.hpp>
|
||||||
#include <boost/unordered/detail/fca.hpp>
|
#include <boost/unordered/detail/fca.hpp>
|
||||||
#include <boost/unordered/detail/opt_storage.hpp>
|
#include <boost/unordered/detail/opt_storage.hpp>
|
||||||
#include <boost/unordered/detail/serialize_tracked_address.hpp>
|
#include <boost/unordered/detail/serialize_tracked_address.hpp>
|
||||||
@ -104,6 +105,10 @@ namespace boost {
|
|||||||
template <class T> no_key(T const&) {}
|
template <class T> no_key(T const&) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct converting_key
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
namespace func {
|
namespace func {
|
||||||
template <class T> inline void ignore_unused_variable_warning(T const&)
|
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)
|
template <typename Key> emplace_return try_emplace_unique(Key&& k)
|
||||||
{
|
{
|
||||||
std::size_t key_hash = this->hash(k);
|
std::size_t key_hash = this->hash(k);
|
||||||
@ -2835,9 +2850,13 @@ namespace boost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class Arg1, class Arg2>
|
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>
|
template <class Arg1, class Arg2, class Arg3, class... Args>
|
||||||
|
@ -18,6 +18,7 @@ namespace boost {
|
|||||||
typedef std::pair<K const, M> value_type;
|
typedef std::pair<K const, M> value_type;
|
||||||
typedef H hasher;
|
typedef H hasher;
|
||||||
typedef P key_equal;
|
typedef P key_equal;
|
||||||
|
typedef K key_type;
|
||||||
typedef K const const_key_type;
|
typedef K const const_key_type;
|
||||||
|
|
||||||
typedef
|
typedef
|
||||||
|
Reference in New Issue
Block a user