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
{ {
bool const pocma= if(this!=&nh){
boost::allocator_propagate_on_container_move_assignment< if(empty()){
Allocator>::type::value; 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=
boost::allocator_propagate_on_container_move_assignment<
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){
if (pocma&&!nh.empty()){al()=std::move(nh.al());} al()=std::move(nh.al());
}
p_=nh.p_;
nh.reset();
}
}
}else{
if(empty()){ /* empty(), nh.empty() */
/* nothing to do */
}else{ /* !empty(), !nh.empty() */
type_policy::destroy(al(),p_);
reset();
}
} }
if(!nh.empty()){
if(empty()){new(&a_.t_)Allocator(std::move(nh.al()));}
p_=nh.p_;
nh.p_=nullptr;
nh.a_.t_.~Allocator();
}else if (!empty()){
a_.t_.~Allocator();
p_=nullptr;
}
return *this; return *this;
} }