From b6c6bfbe7f652ee032d3ae22c0a3e084e7f47f86 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sat, 6 May 2017 04:58:57 +0100 Subject: [PATCH] Statically handle 'is_unique' in assignments --- .../boost/unordered/detail/implementation.hpp | 48 ++++++++----------- include/boost/unordered/unordered_map.hpp | 28 ++++++----- include/boost/unordered/unordered_set.hpp | 28 ++++++----- 3 files changed, 53 insertions(+), 51 deletions(-) diff --git a/include/boost/unordered/detail/implementation.hpp b/include/boost/unordered/detail/implementation.hpp index 419d7d5e..0d3128a5 100644 --- a/include/boost/unordered/detail/implementation.hpp +++ b/include/boost/unordered/detail/implementation.hpp @@ -3098,7 +3098,8 @@ struct table : boost::unordered::detail::functions + 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 + 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 + 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 + 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 + 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 + 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::functionscreate_buckets(this->bucket_count_); @@ -3751,7 +3745,7 @@ struct table : boost::unordered::detail::functions holder(*this); for (node_pointer n = src.begin(); n; n = next_node(n)) { @@ -3760,7 +3754,7 @@ struct table : boost::unordered::detail::functions holder(*this); for (node_pointer n = src.begin(); n; n = next_node(n)) { @@ -4121,7 +4115,7 @@ struct table : boost::unordered::detail::functionscreate_buckets(this->bucket_count_); @@ -4161,7 +4155,7 @@ struct table : boost::unordered::detail::functions holder(*this); for (node_pointer n = src.begin(); n;) { @@ -4175,7 +4169,7 @@ struct table : boost::unordered::detail::functions holder(*this); for (node_pointer n = src.begin(); n;) { diff --git a/include/boost/unordered/unordered_map.hpp b/include/boost/unordered/unordered_map.hpp index a5d3ffa2..25c731ec 100644 --- a/include/boost/unordered/unordered_map.hpp +++ b/include/boost/unordered/unordered_map.hpp @@ -146,7 +146,7 @@ template 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 unordered_map // is_nothrow_move_assignable_v && // is_nothrow_move_assignable_v

) { - 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 unordered_map // is_nothrow_move_assignable_v && // is_nothrow_move_assignable_v

) { - 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 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 unordered_multimap // is_nothrow_move_assignable_v && // is_nothrow_move_assignable_v

) { - 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 unordered_multimap // is_nothrow_move_assignable_v && // is_nothrow_move_assignable_v

) { - 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::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::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::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::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()); } } diff --git a/include/boost/unordered/unordered_set.hpp b/include/boost/unordered/unordered_set.hpp index b160c76e..80137565 100644 --- a/include/boost/unordered/unordered_set.hpp +++ b/include/boost/unordered/unordered_set.hpp @@ -144,7 +144,7 @@ template 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 unordered_set // is_nothrow_move_assignable_v && // is_nothrow_move_assignable_v

) { - 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 unordered_set // is_nothrow_move_assignable_v && // is_nothrow_move_assignable_v

) { - 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 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 unordered_multiset // is_nothrow_move_assignable_v && // is_nothrow_move_assignable_v

) { - 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 unordered_multiset // is_nothrow_move_assignable_v && // is_nothrow_move_assignable_v

) { - 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::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::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::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::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()); } }