Reify implementation of node_handle's move assignment operator

This commit is contained in:
Christian Mazakas
2023-02-19 21:13:37 -08:00
parent 5986f75d16
commit 34ed463bea

View File

@@ -105,32 +105,42 @@ struct node_handle_base
node_handle_base& operator=(node_handle_base&& nh)noexcept node_handle_base& operator=(node_handle_base&& nh)noexcept
{ {
if(this!=&nh){
if(empty()){
if(nh.empty()){ /* empty(), nh.empty() */
/* nothing to do */
}else{ /* empty(), !nh.empty() */
emplace(nh.p_,std::move(nh.al()));
nh.reset();
}
}else{
if(nh.empty()){ /* !empty(), nh.empty() */
type_policy::destroy(al(),p_);
reset();
}else{ /* !empty(), !nh.empty() */
bool const pocma= bool const pocma=
boost::allocator_propagate_on_container_move_assignment< boost::allocator_propagate_on_container_move_assignment<
Allocator>::type::value; Allocator>::type::value;
BOOST_ASSERT( BOOST_ASSERT(pocma||al()==nh.al());
pocma
||empty()
||nh.empty()
||(al()==nh.al()));
if(!empty()){
type_policy::destroy(al(),p_); type_policy::destroy(al(),p_);
if (pocma&&!nh.empty()){al()=std::move(nh.al());} if(pocma){
al()=std::move(nh.al());
} }
if(!nh.empty()){
if(empty()){new(&a_.t_)Allocator(std::move(nh.al()));}
p_=nh.p_; p_=nh.p_;
nh.reset();
nh.p_=nullptr; }
nh.a_.t_.~Allocator(); }
}else if (!empty()){ }else{
a_.t_.~Allocator(); if(empty()){ /* empty(), nh.empty() */
p_=nullptr; /* nothing to do */
}else{ /* !empty(), !nh.empty() */
type_policy::destroy(al(),p_);
reset();
}
} }
return *this; return *this;
} }