Remove Types::is_unique

This commit is contained in:
Daniel James
2017-04-27 18:22:44 +01:00
parent f1435d53d4
commit 03baef8b28
5 changed files with 34 additions and 48 deletions

View File

@ -3116,16 +3116,17 @@ struct table : boost::unordered::detail::functions<typename Types::hasher,
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// Assignment // Assignment
void assign(table const& x) void assign(table const& x, bool is_unique)
{ {
if (this != boost::addressof(x)) { if (this != boost::addressof(x)) {
assign(x, boost::unordered::detail::integral_constant<bool, assign(x, is_unique,
allocator_traits<node_allocator>:: boost::unordered::detail::integral_constant<bool,
propagate_on_container_copy_assignment::value>()); allocator_traits<node_allocator>::
propagate_on_container_copy_assignment::value>());
} }
} }
void assign(table const& x, false_type) void assign(table const& x, bool is_unique, false_type)
{ {
// Strong exception safety. // Strong exception safety.
set_hash_functions new_func_this(*this, x); set_hash_functions new_func_this(*this, x);
@ -3140,18 +3141,18 @@ struct table : boost::unordered::detail::functions<typename Types::hasher,
new_func_this.commit(); new_func_this.commit();
if (Types::is_unique) { if (is_unique) {
assign_buckets_unique(x); assign_buckets_unique(x);
} else { } else {
assign_buckets_equiv(x); assign_buckets_equiv(x);
} }
} }
void assign(table const& x, true_type) void assign(table const& x, bool is_unique, true_type)
{ {
if (node_alloc() == x.node_alloc()) { if (node_alloc() == x.node_alloc()) {
allocators_.assign(x.allocators_); allocators_.assign(x.allocators_);
assign(x, false_type()); assign(x, is_unique, false_type());
} else { } else {
set_hash_functions new_func_this(*this, x); set_hash_functions new_func_this(*this, x);
@ -3167,7 +3168,7 @@ struct table : boost::unordered::detail::functions<typename Types::hasher,
// Finally copy the elements. // Finally copy the elements.
if (x.size_) { if (x.size_) {
if (Types::is_unique) { if (is_unique) {
copy_buckets_unique(x); copy_buckets_unique(x);
} else { } else {
copy_buckets_equiv(x); copy_buckets_equiv(x);
@ -3176,17 +3177,18 @@ struct table : boost::unordered::detail::functions<typename Types::hasher,
} }
} }
void move_assign(table& x) void move_assign(table& x, bool is_unique)
{ {
if (this != boost::addressof(x)) { if (this != boost::addressof(x)) {
move_assign( move_assign(
x, boost::unordered::detail::integral_constant<bool, x, is_unique,
allocator_traits<node_allocator>:: boost::unordered::detail::integral_constant<bool,
propagate_on_container_move_assignment::value>()); allocator_traits<node_allocator>::
propagate_on_container_move_assignment::value>());
} }
} }
void move_assign(table& x, true_type) void move_assign(table& x, bool /* is_unique */, true_type)
{ {
delete_buckets(); delete_buckets();
set_hash_functions new_func_this(*this, x); set_hash_functions new_func_this(*this, x);
@ -3197,7 +3199,7 @@ struct table : boost::unordered::detail::functions<typename Types::hasher,
new_func_this.commit(); new_func_this.commit();
} }
void move_assign(table& x, false_type) void move_assign(table& x, bool is_unique, false_type)
{ {
if (node_alloc() == x.node_alloc()) { if (node_alloc() == x.node_alloc()) {
delete_buckets(); delete_buckets();
@ -3219,7 +3221,7 @@ struct table : boost::unordered::detail::functions<typename Types::hasher,
new_func_this.commit(); new_func_this.commit();
if (Types::is_unique) { if (is_unique) {
move_assign_buckets_unique(x); move_assign_buckets_unique(x);
} else { } else {
move_assign_buckets_equiv(x); move_assign_buckets_equiv(x);

View File

@ -30,10 +30,6 @@ template <typename A, typename K, typename M, typename H, typename P> struct map
typedef boost::unordered::detail::table<types> table; typedef boost::unordered::detail::table<types> table;
typedef boost::unordered::detail::map_extractor<value_type> extractor; typedef boost::unordered::detail::map_extractor<value_type> extractor;
enum
{
is_unique = true
};
typedef typename boost::unordered::detail::pick_policy<K>::type policy; typedef typename boost::unordered::detail::pick_policy<K>::type policy;
@ -71,10 +67,6 @@ struct multimap
typedef boost::unordered::detail::table<types> table; typedef boost::unordered::detail::table<types> table;
typedef boost::unordered::detail::map_extractor<value_type> extractor; typedef boost::unordered::detail::map_extractor<value_type> extractor;
enum
{
is_unique = false
};
typedef typename boost::unordered::detail::pick_policy<K>::type policy; typedef typename boost::unordered::detail::pick_policy<K>::type policy;

View File

@ -30,10 +30,6 @@ template <typename A, typename T, typename H, typename P> struct set
typedef boost::unordered::detail::table<types> table; typedef boost::unordered::detail::table<types> table;
typedef boost::unordered::detail::set_extractor<value_type> extractor; typedef boost::unordered::detail::set_extractor<value_type> extractor;
enum
{
is_unique = true
};
typedef typename boost::unordered::detail::pick_policy<T>::type policy; typedef typename boost::unordered::detail::pick_policy<T>::type policy;
@ -70,10 +66,6 @@ template <typename A, typename T, typename H, typename P> struct multiset
typedef boost::unordered::detail::table<types> table; typedef boost::unordered::detail::table<types> table;
typedef boost::unordered::detail::set_extractor<value_type> extractor; typedef boost::unordered::detail::set_extractor<value_type> extractor;
enum
{
is_unique = false
};
typedef typename boost::unordered::detail::pick_policy<T>::type policy; typedef typename boost::unordered::detail::pick_policy<T>::type policy;

View File

@ -146,7 +146,7 @@ template <class K, class T, class H, class P, class A> class unordered_map
#if defined(BOOST_UNORDERED_USE_MOVE) #if defined(BOOST_UNORDERED_USE_MOVE)
unordered_map& operator=(BOOST_COPY_ASSIGN_REF(unordered_map) x) unordered_map& operator=(BOOST_COPY_ASSIGN_REF(unordered_map) x)
{ {
table_.assign(x.table_); table_.assign(x.table_, true);
return *this; 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<H> &&
// is_nothrow_move_assignable_v<P>) // is_nothrow_move_assignable_v<P>)
{ {
table_.move_assign(x.table_); table_.move_assign(x.table_, true);
return *this; return *this;
} }
#else #else
unordered_map& operator=(unordered_map const& x) unordered_map& operator=(unordered_map const& x)
{ {
table_.assign(x.table_); table_.assign(x.table_, true);
return *this; 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<H> &&
// is_nothrow_move_assignable_v<P>) // is_nothrow_move_assignable_v<P>)
{ {
table_.move_assign(x.table_); table_.move_assign(x.table_, true);
return *this; return *this;
} }
#endif #endif
@ -950,7 +950,7 @@ template <class K, class T, class H, class P, class A> class unordered_multimap
#if defined(BOOST_UNORDERED_USE_MOVE) #if defined(BOOST_UNORDERED_USE_MOVE)
unordered_multimap& operator=(BOOST_COPY_ASSIGN_REF(unordered_multimap) x) unordered_multimap& operator=(BOOST_COPY_ASSIGN_REF(unordered_multimap) x)
{ {
table_.assign(x.table_); table_.assign(x.table_, false);
return *this; return *this;
} }
@ -960,13 +960,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<H> &&
// is_nothrow_move_assignable_v<P>) // is_nothrow_move_assignable_v<P>)
{ {
table_.move_assign(x.table_); table_.move_assign(x.table_, false);
return *this; return *this;
} }
#else #else
unordered_multimap& operator=(unordered_multimap const& x) unordered_multimap& operator=(unordered_multimap const& x)
{ {
table_.assign(x.table_); table_.assign(x.table_, false);
return *this; return *this;
} }
@ -977,7 +977,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<H> &&
// is_nothrow_move_assignable_v<P>) // is_nothrow_move_assignable_v<P>)
{ {
table_.move_assign(x.table_); table_.move_assign(x.table_, false);
return *this; return *this;
} }
#endif #endif

View File

@ -144,7 +144,7 @@ template <class T, class H, class P, class A> class unordered_set
#if defined(BOOST_UNORDERED_USE_MOVE) #if defined(BOOST_UNORDERED_USE_MOVE)
unordered_set& operator=(BOOST_COPY_ASSIGN_REF(unordered_set) x) unordered_set& operator=(BOOST_COPY_ASSIGN_REF(unordered_set) x)
{ {
table_.assign(x.table_); table_.assign(x.table_, true);
return *this; 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<H> &&
// is_nothrow_move_assignable_v<P>) // is_nothrow_move_assignable_v<P>)
{ {
table_.move_assign(x.table_); table_.move_assign(x.table_, true);
return *this; return *this;
} }
#else #else
unordered_set& operator=(unordered_set const& x) unordered_set& operator=(unordered_set const& x)
{ {
table_.assign(x.table_); table_.assign(x.table_, true);
return *this; 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<H> &&
// is_nothrow_move_assignable_v<P>) // is_nothrow_move_assignable_v<P>)
{ {
table_.move_assign(x.table_); table_.move_assign(x.table_, true);
return *this; return *this;
} }
#endif #endif
@ -654,7 +654,7 @@ template <class T, class H, class P, class A> class unordered_multiset
#if defined(BOOST_UNORDERED_USE_MOVE) #if defined(BOOST_UNORDERED_USE_MOVE)
unordered_multiset& operator=(BOOST_COPY_ASSIGN_REF(unordered_multiset) x) unordered_multiset& operator=(BOOST_COPY_ASSIGN_REF(unordered_multiset) x)
{ {
table_.assign(x.table_); table_.assign(x.table_, false);
return *this; 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<H> &&
// is_nothrow_move_assignable_v<P>) // is_nothrow_move_assignable_v<P>)
{ {
table_.move_assign(x.table_); table_.move_assign(x.table_, false);
return *this; return *this;
} }
#else #else
unordered_multiset& operator=(unordered_multiset const& x) unordered_multiset& operator=(unordered_multiset const& x)
{ {
table_.assign(x.table_); table_.assign(x.table_, false);
return *this; 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<H> &&
// is_nothrow_move_assignable_v<P>) // is_nothrow_move_assignable_v<P>)
{ {
table_.move_assign(x.table_); table_.move_assign(x.table_, false);
return *this; return *this;
} }
#endif #endif