mirror of
https://github.com/boostorg/unordered.git
synced 2025-07-29 19:07: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)
|
||||
{
|
||||
x.for_all_elements([&,this](group_type* pg,unsigned int n,element_type* p){
|
||||
if(emplace_impl(type_policy::move(*p)).second){
|
||||
x.erase(iterator{pg,n,p});
|
||||
}
|
||||
erase_on_exit e{x,{pg,n,p}};
|
||||
if(!emplace_impl(type_policy::move(*p)).second)e.rollback();
|
||||
});
|
||||
}
|
||||
|
||||
@ -1569,6 +1568,17 @@ private:
|
||||
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();}
|
||||
const Hash& h()const{return hash_base::get();}
|
||||
Pred& pred(){return pred_base::get();}
|
||||
|
Reference in New Issue
Block a user