mirror of
https://github.com/boostorg/unordered.git
synced 2025-07-30 03:17:15 +02:00
introduced init_type/value_type
This commit is contained in:
@ -828,6 +828,7 @@ table:empty_value<Hash,0>,empty_value<Pred,1>,empty_value<Allocator,1>
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
using key_type=typename type_policy::key_type;
|
using key_type=typename type_policy::key_type;
|
||||||
|
using init_type=typename type_policy::value_type;
|
||||||
using value_type=typename type_policy::value_type;
|
using value_type=typename type_policy::value_type;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -1042,12 +1043,12 @@ public:
|
|||||||
std::forward_as_tuple(std::forward<Args>(args)...));
|
std::forward_as_tuple(std::forward<Args>(args)...));
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_FORCEINLINE std::pair<iterator,bool> insert(const value_type& x)
|
BOOST_FORCEINLINE std::pair<iterator,bool> insert(const init_type& x)
|
||||||
{
|
{
|
||||||
return emplace_impl(x);
|
return emplace_impl(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_FORCEINLINE std::pair<iterator,bool> insert(value_type&& x)
|
BOOST_FORCEINLINE std::pair<iterator,bool> insert(init_type&& x)
|
||||||
{
|
{
|
||||||
return emplace_impl(std::move(x));
|
return emplace_impl(std::move(x));
|
||||||
}
|
}
|
||||||
@ -1346,8 +1347,9 @@ private:
|
|||||||
void nosize_transfer_element(value_type* p,const arrays_type& arrays_)
|
void nosize_transfer_element(value_type* p,const arrays_type& arrays_)
|
||||||
{
|
{
|
||||||
auto hash=h()(key_from(*p));
|
auto hash=h()(key_from(*p));
|
||||||
nosize_unchecked_emplace_at(
|
type_policy::move_parts_to(
|
||||||
arrays_,position_for(hash,arrays_),hash,std::move(*p));
|
*p,
|
||||||
|
bind_unchecked_emplace_at{this,arrays_,position_for(hash,arrays_),hash});
|
||||||
destroy_element(p);
|
destroy_element(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1413,6 +1415,21 @@ private:
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
struct bind_unchecked_emplace_at
|
||||||
|
{
|
||||||
|
template<typename... Args>
|
||||||
|
iterator operator()(Args&&... args)const
|
||||||
|
{
|
||||||
|
return this_->nosize_unchecked_emplace_at(
|
||||||
|
arrays,pos0,hash,std::forward<Args>(args)...);
|
||||||
|
}
|
||||||
|
|
||||||
|
table* this_;
|
||||||
|
const arrays_type& arrays;
|
||||||
|
std::size_t pos0;
|
||||||
|
std::size_t hash;
|
||||||
|
};
|
||||||
|
|
||||||
template<typename F>
|
template<typename F>
|
||||||
void for_all_elements(F f)const
|
void for_all_elements(F f)const
|
||||||
{
|
{
|
||||||
|
@ -28,8 +28,16 @@ namespace boost {
|
|||||||
struct map_types
|
struct map_types
|
||||||
{
|
{
|
||||||
using key_type = Key;
|
using key_type = Key;
|
||||||
|
using init_type = std::pair<Key, T>;
|
||||||
using value_type = std::pair<Key const, T>;
|
using value_type = std::pair<Key const, T>;
|
||||||
static Key const& extract(value_type const& kv) { return kv.first; }
|
static Key const& extract(value_type const& kv) { return kv.first; }
|
||||||
|
|
||||||
|
template<typename F>
|
||||||
|
static void move_parts_to(value_type& x,F f)
|
||||||
|
{
|
||||||
|
// TODO: we probably need to launder here
|
||||||
|
f(std::move(const_cast<Key&>(x.first)), std::move(x.second));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
using table_type = detail::foa::table<map_types, Hash, KeyEqual,
|
using table_type = detail::foa::table<map_types, Hash, KeyEqual,
|
||||||
|
@ -28,8 +28,12 @@ namespace boost {
|
|||||||
struct set_types
|
struct set_types
|
||||||
{
|
{
|
||||||
using key_type = Key;
|
using key_type = Key;
|
||||||
|
using init_type = Key;
|
||||||
using value_type = Key;
|
using value_type = Key;
|
||||||
static Key const& extract(value_type const& key) { return key; }
|
static Key const& extract(value_type const& key) { return key; }
|
||||||
|
|
||||||
|
template<typename F>
|
||||||
|
static void move_parts_to(value_type& x,F f) { f(std::move(x)); }
|
||||||
};
|
};
|
||||||
|
|
||||||
using table_type = detail::foa::table<set_types, Hash, KeyEqual,
|
using table_type = detail::foa::table<set_types, Hash, KeyEqual,
|
||||||
|
Reference in New Issue
Block a user