forked from boostorg/unordered
operator= noexcept support
This commit is contained in:
@@ -3540,49 +3540,86 @@ namespace boost {
|
||||
move_assign(x, is_unique,
|
||||
boost::unordered::detail::integral_constant<bool,
|
||||
allocator_traits<node_allocator>::
|
||||
propagate_on_container_move_assignment::value>());
|
||||
propagate_on_container_move_assignment::value>(),
|
||||
boost::unordered::detail::integral_constant<bool,
|
||||
functions::nothrow_move_assignable>());
|
||||
}
|
||||
}
|
||||
|
||||
// Propagate allocator, move assign functions throwable
|
||||
template <typename UniqueType>
|
||||
void move_assign(table& x, UniqueType, true_type)
|
||||
void move_assign(table& x, UniqueType, true_type, false_type)
|
||||
{
|
||||
delete_buckets();
|
||||
set_hash_functions new_func_this(*this, x);
|
||||
// TODO: Can this throw? If so then breaks noexcept spec.
|
||||
// Maybe don't do it if allocators are equal.
|
||||
delete_buckets();
|
||||
allocators_.move_assign(x.allocators_);
|
||||
// No throw from here.
|
||||
mlf_ = x.mlf_;
|
||||
move_buckets_from(x);
|
||||
new_func_this.commit();
|
||||
}
|
||||
|
||||
// Propagate allocator, move assign functions noexcept
|
||||
template <typename UniqueType>
|
||||
void move_assign(table& x, UniqueType is_unique, false_type)
|
||||
void move_assign(table& x, UniqueType, true_type, true_type)
|
||||
{
|
||||
delete_buckets();
|
||||
allocators_.move_assign(x.allocators_);
|
||||
mlf_ = x.mlf_;
|
||||
move_buckets_from(x);
|
||||
this->current_functions().move_assign(x.current_functions());
|
||||
}
|
||||
|
||||
// Don't propagate allocator
|
||||
template <typename UniqueType, typename IsNoExcept>
|
||||
void move_assign(
|
||||
table& x, UniqueType is_unique, false_type, IsNoExcept is_noexcept)
|
||||
{
|
||||
if (node_alloc() == x.node_alloc()) {
|
||||
delete_buckets();
|
||||
set_hash_functions new_func_this(*this, x);
|
||||
// No throw from here.
|
||||
mlf_ = x.mlf_;
|
||||
move_buckets_from(x);
|
||||
new_func_this.commit();
|
||||
move_assign_equal_alloc(x, is_noexcept);
|
||||
} else {
|
||||
set_hash_functions new_func_this(*this, x);
|
||||
mlf_ = x.mlf_;
|
||||
recalculate_max_load();
|
||||
|
||||
if (x.size_ > max_load_) {
|
||||
create_buckets(min_buckets_for_size(x.size_));
|
||||
} else if (size_) {
|
||||
clear_buckets();
|
||||
}
|
||||
|
||||
new_func_this.commit();
|
||||
|
||||
move_assign_buckets(x, is_unique);
|
||||
move_assign_realloc(x, is_unique);
|
||||
}
|
||||
}
|
||||
|
||||
// Move assign functions throwable
|
||||
void move_assign_equal_alloc(table& x, false_type)
|
||||
{
|
||||
set_hash_functions new_func_this(*this, x);
|
||||
delete_buckets();
|
||||
mlf_ = x.mlf_;
|
||||
move_buckets_from(x);
|
||||
new_func_this.commit();
|
||||
}
|
||||
|
||||
// Move assign functions noexcept
|
||||
void move_assign_equal_alloc(table& x, true_type)
|
||||
{
|
||||
delete_buckets();
|
||||
mlf_ = x.mlf_;
|
||||
move_buckets_from(x);
|
||||
this->current_functions().move_assign(x.current_functions());
|
||||
}
|
||||
|
||||
template <typename UniqueType>
|
||||
void move_assign_realloc(table& x, UniqueType is_unique)
|
||||
{
|
||||
set_hash_functions new_func_this(*this, x);
|
||||
mlf_ = x.mlf_;
|
||||
recalculate_max_load();
|
||||
|
||||
if (x.size_ > max_load_) {
|
||||
create_buckets(min_buckets_for_size(x.size_));
|
||||
} else if (size_) {
|
||||
clear_buckets();
|
||||
}
|
||||
|
||||
new_func_this.commit();
|
||||
|
||||
move_assign_buckets(x, is_unique);
|
||||
}
|
||||
|
||||
// Accessors
|
||||
|
||||
const_key_type& get_key(node_pointer n) const
|
||||
|
||||
@@ -151,10 +151,9 @@ namespace boost {
|
||||
}
|
||||
|
||||
unordered_map& operator=(BOOST_RV_REF(unordered_map) x)
|
||||
// C++17 support: BOOST_NOEXCEPT_IF(
|
||||
// value_allocator_traits::is_always_equal::value &&
|
||||
// is_nothrow_move_assignable_v<H> &&
|
||||
// is_nothrow_move_assignable_v<P>)
|
||||
BOOST_NOEXCEPT_IF(value_allocator_traits::is_always_equal::value&&
|
||||
boost::is_nothrow_move_assignable<H>::value&&
|
||||
boost::is_nothrow_move_assignable<P>::value)
|
||||
{
|
||||
table_.move_assign(x.table_, boost::unordered::detail::true_type());
|
||||
return *this;
|
||||
@@ -168,10 +167,9 @@ namespace boost {
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
unordered_map& operator=(unordered_map&& x)
|
||||
// C++17 support: BOOST_NOEXCEPT_IF(
|
||||
// value_allocator_traits::is_always_equal::value &&
|
||||
// is_nothrow_move_assignable_v<H> &&
|
||||
// is_nothrow_move_assignable_v<P>)
|
||||
BOOST_NOEXCEPT_IF(value_allocator_traits::is_always_equal::value&&
|
||||
boost::is_nothrow_move_assignable<H>::value&&
|
||||
boost::is_nothrow_move_assignable<P>::value)
|
||||
{
|
||||
table_.move_assign(x.table_, boost::unordered::detail::true_type());
|
||||
return *this;
|
||||
@@ -1023,10 +1021,9 @@ namespace boost {
|
||||
}
|
||||
|
||||
unordered_multimap& operator=(BOOST_RV_REF(unordered_multimap) x)
|
||||
// C++17 support: BOOST_NOEXCEPT_IF(
|
||||
// value_allocator_traits::is_always_equal::value &&
|
||||
// is_nothrow_move_assignable_v<H> &&
|
||||
// is_nothrow_move_assignable_v<P>)
|
||||
BOOST_NOEXCEPT_IF(value_allocator_traits::is_always_equal::value&&
|
||||
boost::is_nothrow_move_assignable<H>::value&&
|
||||
boost::is_nothrow_move_assignable<P>::value)
|
||||
{
|
||||
table_.move_assign(x.table_, boost::unordered::detail::false_type());
|
||||
return *this;
|
||||
@@ -1040,10 +1037,9 @@ namespace boost {
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
unordered_multimap& operator=(unordered_multimap&& x)
|
||||
// C++17 support: BOOST_NOEXCEPT_IF(
|
||||
// value_allocator_traits::is_always_equal::value &&
|
||||
// is_nothrow_move_assignable_v<H> &&
|
||||
// is_nothrow_move_assignable_v<P>)
|
||||
BOOST_NOEXCEPT_IF(value_allocator_traits::is_always_equal::value&&
|
||||
boost::is_nothrow_move_assignable<H>::value&&
|
||||
boost::is_nothrow_move_assignable<P>::value)
|
||||
{
|
||||
table_.move_assign(x.table_, boost::unordered::detail::false_type());
|
||||
return *this;
|
||||
|
||||
@@ -149,10 +149,9 @@ namespace boost {
|
||||
}
|
||||
|
||||
unordered_set& operator=(BOOST_RV_REF(unordered_set) x)
|
||||
// C++17 support: BOOST_NOEXCEPT_IF(
|
||||
// value_allocator_traits::is_always_equal::value &&
|
||||
// is_nothrow_move_assignable_v<H> &&
|
||||
// is_nothrow_move_assignable_v<P>)
|
||||
BOOST_NOEXCEPT_IF(value_allocator_traits::is_always_equal::value&&
|
||||
boost::is_nothrow_move_assignable<H>::value&&
|
||||
boost::is_nothrow_move_assignable<P>::value)
|
||||
{
|
||||
table_.move_assign(x.table_, boost::unordered::detail::true_type());
|
||||
return *this;
|
||||
@@ -166,10 +165,9 @@ namespace boost {
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
unordered_set& operator=(unordered_set&& x)
|
||||
// C++17 support: BOOST_NOEXCEPT_IF(
|
||||
// value_allocator_traits::is_always_equal::value &&
|
||||
// is_nothrow_move_assignable_v<H> &&
|
||||
// is_nothrow_move_assignable_v<P>)
|
||||
BOOST_NOEXCEPT_IF(value_allocator_traits::is_always_equal::value&&
|
||||
boost::is_nothrow_move_assignable<H>::value&&
|
||||
boost::is_nothrow_move_assignable<P>::value)
|
||||
{
|
||||
table_.move_assign(x.table_, boost::unordered::detail::true_type());
|
||||
return *this;
|
||||
@@ -706,10 +704,9 @@ namespace boost {
|
||||
}
|
||||
|
||||
unordered_multiset& operator=(BOOST_RV_REF(unordered_multiset) x)
|
||||
// C++17 support: BOOST_NOEXCEPT_IF(
|
||||
// value_allocator_traits::is_always_equal::value &&
|
||||
// is_nothrow_move_assignable_v<H> &&
|
||||
// is_nothrow_move_assignable_v<P>)
|
||||
BOOST_NOEXCEPT_IF(value_allocator_traits::is_always_equal::value&&
|
||||
boost::is_nothrow_move_assignable<H>::value&&
|
||||
boost::is_nothrow_move_assignable<P>::value)
|
||||
{
|
||||
table_.move_assign(x.table_, boost::unordered::detail::false_type());
|
||||
return *this;
|
||||
@@ -723,10 +720,9 @@ namespace boost {
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
unordered_multiset& operator=(unordered_multiset&& x)
|
||||
// C++17 support: BOOST_NOEXCEPT_IF(
|
||||
// value_allocator_traits::is_always_equal::value &&
|
||||
// is_nothrow_move_assignable_v<H> &&
|
||||
// is_nothrow_move_assignable_v<P>)
|
||||
BOOST_NOEXCEPT_IF(value_allocator_traits::is_always_equal::value&&
|
||||
boost::is_nothrow_move_assignable<H>::value&&
|
||||
boost::is_nothrow_move_assignable<P>::value)
|
||||
{
|
||||
table_.move_assign(x.table_, boost::unordered::detail::false_type());
|
||||
return *this;
|
||||
|
||||
Reference in New Issue
Block a user