mirror of
https://github.com/boostorg/unordered.git
synced 2025-07-30 19:37:14 +02:00
refactored table's allocator-extended copy tor
This commit is contained in:
@ -1109,7 +1109,7 @@ public:
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
table(const table& x):
|
table(const table& x):
|
||||||
table(x,alloc_traits::select_on_container_copy_construction(x.al())){}
|
table{x,alloc_traits::select_on_container_copy_construction(x.al())}{}
|
||||||
|
|
||||||
table(table&& x)
|
table(table&& x)
|
||||||
noexcept(
|
noexcept(
|
||||||
@ -1127,22 +1127,11 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
table(const table& x,const Allocator& al_):
|
table(const table& x,const Allocator& al_):
|
||||||
hash_base{empty_init,x.h()},pred_base{empty_init,x.pred()},
|
table{std::size_t(std::ceil(float(x.size())/mlf)),x.h(),x.pred(),al_}
|
||||||
allocator_base{empty_init,al_},size_{0},
|
|
||||||
arrays(
|
|
||||||
new_arrays(std::size_t(std::ceil(static_cast<float>(x.size())/mlf)))),
|
|
||||||
ml{max_load()}
|
|
||||||
{
|
{
|
||||||
BOOST_TRY{
|
x.for_all_elements([this](value_type* p){
|
||||||
x.for_all_elements([this](value_type* p){
|
unchecked_insert(*p);
|
||||||
unchecked_insert(*p);
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
BOOST_CATCH(...){
|
|
||||||
destroy();
|
|
||||||
BOOST_RETHROW
|
|
||||||
}
|
|
||||||
BOOST_CATCH_END
|
|
||||||
}
|
}
|
||||||
|
|
||||||
table(table&& x,const Allocator& al_):
|
table(table&& x,const Allocator& al_):
|
||||||
@ -1178,7 +1167,10 @@ public:
|
|||||||
|
|
||||||
~table()noexcept
|
~table()noexcept
|
||||||
{
|
{
|
||||||
destroy();
|
for_all_elements([this](value_type* p){
|
||||||
|
destroy_element(p);
|
||||||
|
});
|
||||||
|
delete_arrays(arrays);
|
||||||
}
|
}
|
||||||
|
|
||||||
table& operator=(const table& x)
|
table& operator=(const table& x)
|
||||||
@ -1467,14 +1459,6 @@ private:
|
|||||||
Allocator& al(){return allocator_base::get();}
|
Allocator& al(){return allocator_base::get();}
|
||||||
const Allocator& al()const{return allocator_base::get();}
|
const Allocator& al()const{return allocator_base::get();}
|
||||||
|
|
||||||
void destroy()noexcept
|
|
||||||
{
|
|
||||||
for_all_elements([this](value_type* p){
|
|
||||||
destroy_element(p);
|
|
||||||
});
|
|
||||||
delete_arrays(arrays);
|
|
||||||
}
|
|
||||||
|
|
||||||
arrays_type new_arrays(std::size_t n)
|
arrays_type new_arrays(std::size_t n)
|
||||||
{
|
{
|
||||||
return arrays_type::new_(al(),n);
|
return arrays_type::new_(al(),n);
|
||||||
|
Reference in New Issue
Block a user