mirror of
https://github.com/boostorg/unordered.git
synced 2025-07-30 11:27:15 +02:00
fixed bug with dangling moved element on throwing rehash during merge
This commit is contained in:
committed by
Christian Mazakas
parent
8da44f4f46
commit
53e4531295
@ -1499,9 +1499,8 @@ public:
|
|||||||
void merge(table<TypePolicy,Hash2,Pred2,Allocator>& x)
|
void merge(table<TypePolicy,Hash2,Pred2,Allocator>& x)
|
||||||
{
|
{
|
||||||
x.for_all_elements([&,this](group_type* pg,unsigned int n,element_type* p){
|
x.for_all_elements([&,this](group_type* pg,unsigned int n,element_type* p){
|
||||||
if(emplace_impl(type_policy::move(*p)).second){
|
erase_on_exit e{x,{pg,n,p}};
|
||||||
x.erase(iterator{pg,n,p});
|
if(!emplace_impl(type_policy::move(*p)).second)e.rollback();
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1569,6 +1568,17 @@ private:
|
|||||||
table& x;
|
table& x;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct erase_on_exit
|
||||||
|
{
|
||||||
|
~erase_on_exit(){if(!rollback_)x.erase(it);}
|
||||||
|
|
||||||
|
void rollback(){rollback_=true;}
|
||||||
|
|
||||||
|
table& x;
|
||||||
|
iterator it;
|
||||||
|
bool rollback_=false;
|
||||||
|
};
|
||||||
|
|
||||||
Hash& h(){return hash_base::get();}
|
Hash& h(){return hash_base::get();}
|
||||||
const Hash& h()const{return hash_base::get();}
|
const Hash& h()const{return hash_base::get();}
|
||||||
Pred& pred(){return pred_base::get();}
|
Pred& pred(){return pred_base::get();}
|
||||||
|
Reference in New Issue
Block a user