mirror of
https://github.com/boostorg/unordered.git
synced 2025-07-29 19:07:15 +02:00
Statically handle 'is_unique' in assignments
This commit is contained in:
@ -3098,7 +3098,8 @@ struct table : boost::unordered::detail::functions<typename Types::hasher,
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Assignment
|
||||
|
||||
void assign(table const& x, bool is_unique)
|
||||
template <typename UniqueType>
|
||||
void assign(table const& x, UniqueType is_unique)
|
||||
{
|
||||
if (this != boost::addressof(x)) {
|
||||
assign(x, is_unique,
|
||||
@ -3108,7 +3109,8 @@ struct table : boost::unordered::detail::functions<typename Types::hasher,
|
||||
}
|
||||
}
|
||||
|
||||
void assign(table const& x, bool is_unique, false_type)
|
||||
template <typename UniqueType>
|
||||
void assign(table const& x, UniqueType is_unique, false_type)
|
||||
{
|
||||
// Strong exception safety.
|
||||
set_hash_functions new_func_this(*this, x);
|
||||
@ -3123,14 +3125,11 @@ struct table : boost::unordered::detail::functions<typename Types::hasher,
|
||||
|
||||
new_func_this.commit();
|
||||
|
||||
if (is_unique) {
|
||||
assign_buckets_unique(x);
|
||||
} else {
|
||||
assign_buckets_equiv(x);
|
||||
}
|
||||
assign_buckets(x, is_unique);
|
||||
}
|
||||
|
||||
void assign(table const& x, bool is_unique, true_type)
|
||||
template <typename UniqueType>
|
||||
void assign(table const& x, UniqueType is_unique, true_type)
|
||||
{
|
||||
if (node_alloc() == x.node_alloc()) {
|
||||
allocators_.assign(x.allocators_);
|
||||
@ -3150,16 +3149,13 @@ struct table : boost::unordered::detail::functions<typename Types::hasher,
|
||||
|
||||
// Finally copy the elements.
|
||||
if (x.size_) {
|
||||
if (is_unique) {
|
||||
copy_buckets_unique(x);
|
||||
} else {
|
||||
copy_buckets_equiv(x);
|
||||
}
|
||||
copy_buckets(x, is_unique);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void move_assign(table& x, bool is_unique)
|
||||
template <typename UniqueType>
|
||||
void move_assign(table& x, UniqueType is_unique)
|
||||
{
|
||||
if (this != boost::addressof(x)) {
|
||||
move_assign(
|
||||
@ -3170,7 +3166,8 @@ struct table : boost::unordered::detail::functions<typename Types::hasher,
|
||||
}
|
||||
}
|
||||
|
||||
void move_assign(table& x, bool /* is_unique */, true_type)
|
||||
template <typename UniqueType>
|
||||
void move_assign(table& x, UniqueType, true_type)
|
||||
{
|
||||
delete_buckets();
|
||||
set_hash_functions new_func_this(*this, x);
|
||||
@ -3181,7 +3178,8 @@ struct table : boost::unordered::detail::functions<typename Types::hasher,
|
||||
new_func_this.commit();
|
||||
}
|
||||
|
||||
void move_assign(table& x, bool is_unique, false_type)
|
||||
template <typename UniqueType>
|
||||
void move_assign(table& x, UniqueType is_unique, false_type)
|
||||
{
|
||||
if (node_alloc() == x.node_alloc()) {
|
||||
delete_buckets();
|
||||
@ -3203,11 +3201,7 @@ struct table : boost::unordered::detail::functions<typename Types::hasher,
|
||||
|
||||
new_func_this.commit();
|
||||
|
||||
if (is_unique) {
|
||||
move_assign_buckets_unique(x);
|
||||
} else {
|
||||
move_assign_buckets_equiv(x);
|
||||
}
|
||||
move_assign_buckets(x, is_unique);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3724,7 +3718,7 @@ struct table : boost::unordered::detail::functions<typename Types::hasher,
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// fill_buckets_unique
|
||||
|
||||
void copy_buckets_unique(table const& src)
|
||||
void copy_buckets(table const& src, true_type)
|
||||
{
|
||||
this->create_buckets(this->bucket_count_);
|
||||
|
||||
@ -3751,7 +3745,7 @@ struct table : boost::unordered::detail::functions<typename Types::hasher,
|
||||
}
|
||||
}
|
||||
|
||||
void assign_buckets_unique(table const& src)
|
||||
void assign_buckets(table const& src, true_type)
|
||||
{
|
||||
node_holder<node_allocator> holder(*this);
|
||||
for (node_pointer n = src.begin(); n; n = next_node(n)) {
|
||||
@ -3760,7 +3754,7 @@ struct table : boost::unordered::detail::functions<typename Types::hasher,
|
||||
}
|
||||
}
|
||||
|
||||
void move_assign_buckets_unique(table& src)
|
||||
void move_assign_buckets(table& src, true_type)
|
||||
{
|
||||
node_holder<node_allocator> holder(*this);
|
||||
for (node_pointer n = src.begin(); n; n = next_node(n)) {
|
||||
@ -4121,7 +4115,7 @@ struct table : boost::unordered::detail::functions<typename Types::hasher,
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// fill_buckets
|
||||
|
||||
void copy_buckets_equiv(table const& src)
|
||||
void copy_buckets(table const& src, false_type)
|
||||
{
|
||||
this->create_buckets(this->bucket_count_);
|
||||
|
||||
@ -4161,7 +4155,7 @@ struct table : boost::unordered::detail::functions<typename Types::hasher,
|
||||
}
|
||||
}
|
||||
|
||||
void assign_buckets_equiv(table const& src)
|
||||
void assign_buckets(table const& src, false_type)
|
||||
{
|
||||
node_holder<node_allocator> holder(*this);
|
||||
for (node_pointer n = src.begin(); n;) {
|
||||
@ -4175,7 +4169,7 @@ struct table : boost::unordered::detail::functions<typename Types::hasher,
|
||||
}
|
||||
}
|
||||
|
||||
void move_assign_buckets_equiv(table& src)
|
||||
void move_assign_buckets(table& src, false_type)
|
||||
{
|
||||
node_holder<node_allocator> holder(*this);
|
||||
for (node_pointer n = src.begin(); n;) {
|
||||
|
@ -146,7 +146,7 @@ template <class K, class T, class H, class P, class A> class unordered_map
|
||||
#if defined(BOOST_UNORDERED_USE_MOVE)
|
||||
unordered_map& operator=(BOOST_COPY_ASSIGN_REF(unordered_map) x)
|
||||
{
|
||||
table_.assign(x.table_, true);
|
||||
table_.assign(x.table_, boost::unordered::detail::true_type());
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -156,13 +156,13 @@ template <class K, class T, class H, class P, class A> class unordered_map
|
||||
// is_nothrow_move_assignable_v<H> &&
|
||||
// is_nothrow_move_assignable_v<P>)
|
||||
{
|
||||
table_.move_assign(x.table_, true);
|
||||
table_.move_assign(x.table_, boost::unordered::detail::true_type());
|
||||
return *this;
|
||||
}
|
||||
#else
|
||||
unordered_map& operator=(unordered_map const& x)
|
||||
{
|
||||
table_.assign(x.table_, true);
|
||||
table_.assign(x.table_, boost::unordered::detail::true_type());
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -173,7 +173,7 @@ template <class K, class T, class H, class P, class A> class unordered_map
|
||||
// is_nothrow_move_assignable_v<H> &&
|
||||
// is_nothrow_move_assignable_v<P>)
|
||||
{
|
||||
table_.move_assign(x.table_, true);
|
||||
table_.move_assign(x.table_, boost::unordered::detail::true_type());
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
@ -948,7 +948,7 @@ template <class K, class T, class H, class P, class A> class unordered_multimap
|
||||
#if defined(BOOST_UNORDERED_USE_MOVE)
|
||||
unordered_multimap& operator=(BOOST_COPY_ASSIGN_REF(unordered_multimap) x)
|
||||
{
|
||||
table_.assign(x.table_, false);
|
||||
table_.assign(x.table_, boost::unordered::detail::false_type());
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -958,13 +958,13 @@ template <class K, class T, class H, class P, class A> class unordered_multimap
|
||||
// is_nothrow_move_assignable_v<H> &&
|
||||
// is_nothrow_move_assignable_v<P>)
|
||||
{
|
||||
table_.move_assign(x.table_, false);
|
||||
table_.move_assign(x.table_, boost::unordered::detail::false_type());
|
||||
return *this;
|
||||
}
|
||||
#else
|
||||
unordered_multimap& operator=(unordered_multimap const& x)
|
||||
{
|
||||
table_.assign(x.table_, false);
|
||||
table_.assign(x.table_, boost::unordered::detail::false_type());
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -975,7 +975,7 @@ template <class K, class T, class H, class P, class A> class unordered_multimap
|
||||
// is_nothrow_move_assignable_v<H> &&
|
||||
// is_nothrow_move_assignable_v<P>)
|
||||
{
|
||||
table_.move_assign(x.table_, false);
|
||||
table_.move_assign(x.table_, boost::unordered::detail::false_type());
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
@ -1399,7 +1399,8 @@ unordered_map<K, T, H, P, A>::unordered_map(unordered_map const& other)
|
||||
select_on_container_copy_construction(other.get_allocator()))
|
||||
{
|
||||
if (other.table_.size_) {
|
||||
table_.copy_buckets_unique(other.table_);
|
||||
table_.copy_buckets(
|
||||
other.table_, boost::unordered::detail::true_type());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1416,7 +1417,8 @@ unordered_map<K, T, H, P, A>::unordered_map(
|
||||
: table_(other.table_, a)
|
||||
{
|
||||
if (other.table_.size_) {
|
||||
table_.copy_buckets_unique(other.table_);
|
||||
table_.copy_buckets(
|
||||
other.table_, boost::unordered::detail::true_type());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1877,7 +1879,8 @@ unordered_multimap<K, T, H, P, A>::unordered_multimap(
|
||||
select_on_container_copy_construction(other.get_allocator()))
|
||||
{
|
||||
if (other.table_.size_) {
|
||||
table_.copy_buckets_equiv(other.table_);
|
||||
table_.copy_buckets(
|
||||
other.table_, boost::unordered::detail::false_type());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1894,7 +1897,8 @@ unordered_multimap<K, T, H, P, A>::unordered_multimap(
|
||||
: table_(other.table_, a)
|
||||
{
|
||||
if (other.table_.size_) {
|
||||
table_.copy_buckets_equiv(other.table_);
|
||||
table_.copy_buckets(
|
||||
other.table_, boost::unordered::detail::false_type());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,7 +144,7 @@ template <class T, class H, class P, class A> class unordered_set
|
||||
#if defined(BOOST_UNORDERED_USE_MOVE)
|
||||
unordered_set& operator=(BOOST_COPY_ASSIGN_REF(unordered_set) x)
|
||||
{
|
||||
table_.assign(x.table_, true);
|
||||
table_.assign(x.table_, boost::unordered::detail::true_type());
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -154,13 +154,13 @@ template <class T, class H, class P, class A> class unordered_set
|
||||
// is_nothrow_move_assignable_v<H> &&
|
||||
// is_nothrow_move_assignable_v<P>)
|
||||
{
|
||||
table_.move_assign(x.table_, true);
|
||||
table_.move_assign(x.table_, boost::unordered::detail::true_type());
|
||||
return *this;
|
||||
}
|
||||
#else
|
||||
unordered_set& operator=(unordered_set const& x)
|
||||
{
|
||||
table_.assign(x.table_, true);
|
||||
table_.assign(x.table_, boost::unordered::detail::true_type());
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -171,7 +171,7 @@ template <class T, class H, class P, class A> class unordered_set
|
||||
// is_nothrow_move_assignable_v<H> &&
|
||||
// is_nothrow_move_assignable_v<P>)
|
||||
{
|
||||
table_.move_assign(x.table_, true);
|
||||
table_.move_assign(x.table_, boost::unordered::detail::true_type());
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
@ -654,7 +654,7 @@ template <class T, class H, class P, class A> class unordered_multiset
|
||||
#if defined(BOOST_UNORDERED_USE_MOVE)
|
||||
unordered_multiset& operator=(BOOST_COPY_ASSIGN_REF(unordered_multiset) x)
|
||||
{
|
||||
table_.assign(x.table_, false);
|
||||
table_.assign(x.table_, boost::unordered::detail::false_type());
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -664,13 +664,13 @@ template <class T, class H, class P, class A> class unordered_multiset
|
||||
// is_nothrow_move_assignable_v<H> &&
|
||||
// is_nothrow_move_assignable_v<P>)
|
||||
{
|
||||
table_.move_assign(x.table_, false);
|
||||
table_.move_assign(x.table_, boost::unordered::detail::false_type());
|
||||
return *this;
|
||||
}
|
||||
#else
|
||||
unordered_multiset& operator=(unordered_multiset const& x)
|
||||
{
|
||||
table_.assign(x.table_, false);
|
||||
table_.assign(x.table_, boost::unordered::detail::false_type());
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -681,7 +681,7 @@ template <class T, class H, class P, class A> class unordered_multiset
|
||||
// is_nothrow_move_assignable_v<H> &&
|
||||
// is_nothrow_move_assignable_v<P>)
|
||||
{
|
||||
table_.move_assign(x.table_, false);
|
||||
table_.move_assign(x.table_, boost::unordered::detail::false_type());
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
@ -1078,7 +1078,8 @@ unordered_set<T, H, P, A>::unordered_set(unordered_set const& other)
|
||||
select_on_container_copy_construction(other.get_allocator()))
|
||||
{
|
||||
if (other.table_.size_) {
|
||||
table_.copy_buckets_unique(other.table_);
|
||||
table_.copy_buckets(
|
||||
other.table_, boost::unordered::detail::true_type());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1095,7 +1096,8 @@ unordered_set<T, H, P, A>::unordered_set(
|
||||
: table_(other.table_, a)
|
||||
{
|
||||
if (other.table_.size_) {
|
||||
table_.copy_buckets_unique(other.table_);
|
||||
table_.copy_buckets(
|
||||
other.table_, boost::unordered::detail::true_type());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1472,7 +1474,8 @@ unordered_multiset<T, H, P, A>::unordered_multiset(
|
||||
select_on_container_copy_construction(other.get_allocator()))
|
||||
{
|
||||
if (other.table_.size_) {
|
||||
table_.copy_buckets_equiv(other.table_);
|
||||
table_.copy_buckets(
|
||||
other.table_, boost::unordered::detail::false_type());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1489,7 +1492,8 @@ unordered_multiset<T, H, P, A>::unordered_multiset(
|
||||
: table_(other.table_, a)
|
||||
{
|
||||
if (other.table_.size_) {
|
||||
table_.copy_buckets_equiv(other.table_);
|
||||
table_.copy_buckets(
|
||||
other.table_, boost::unordered::detail::false_type());
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user