mirror of
https://github.com/boostorg/unordered.git
synced 2025-07-30 03:17:15 +02:00
Reify implementation of node_handle's swap
This commit is contained in:
@ -160,33 +160,30 @@ struct node_handle_base
|
|||||||
boost::allocator_is_always_equal<Allocator>::type::value||
|
boost::allocator_is_always_equal<Allocator>::type::value||
|
||||||
boost::allocator_propagate_on_container_swap<Allocator>::type::value)
|
boost::allocator_propagate_on_container_swap<Allocator>::type::value)
|
||||||
{
|
{
|
||||||
using std::swap;
|
if(this!=&nh){
|
||||||
|
if(empty()){
|
||||||
|
if(nh.empty()) {
|
||||||
|
/* nothing to do here */
|
||||||
|
} else {
|
||||||
|
emplace(nh.p_, nh.al());
|
||||||
|
nh.reset();
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if(nh.empty()){
|
||||||
|
nh.emplace(p_,al());
|
||||||
|
reset();
|
||||||
|
}else{
|
||||||
|
bool const pocs=
|
||||||
|
boost::allocator_propagate_on_container_swap<
|
||||||
|
Allocator>::type::value;
|
||||||
|
|
||||||
bool const pocs=
|
BOOST_ASSERT(pocs || al()==nh.al());
|
||||||
boost::allocator_propagate_on_container_swap<Allocator>::type::value;
|
|
||||||
|
|
||||||
if (!empty()&&!nh.empty()){
|
using std::swap;
|
||||||
BOOST_ASSERT(pocs || al()==nh.al());
|
swap(p_,nh.p_);
|
||||||
|
if(pocs)swap(al(),nh.al());
|
||||||
node_value_type *p=p_;
|
}
|
||||||
p_=nh.p_;
|
|
||||||
nh.p_=p;
|
|
||||||
|
|
||||||
if(pocs){
|
|
||||||
swap(al(),nh.al());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty()&&nh.empty()){return;}
|
|
||||||
|
|
||||||
if (empty()){
|
|
||||||
emplace(nh.p_,nh.al());
|
|
||||||
nh.clear();
|
|
||||||
}else{
|
|
||||||
nh.emplace(p_,al());
|
|
||||||
clear();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user