From a200af610f64dbdbc4210eecd3977d22006fa35a Mon Sep 17 00:00:00 2001 From: joaquintides Date: Tue, 18 Oct 2022 15:41:33 +0200 Subject: [PATCH] refactored table's allocator-extended copy tor --- include/boost/unordered/detail/foa.hpp | 34 +++++++------------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/include/boost/unordered/detail/foa.hpp b/include/boost/unordered/detail/foa.hpp index a707fb1d..d75d842b 100644 --- a/include/boost/unordered/detail/foa.hpp +++ b/include/boost/unordered/detail/foa.hpp @@ -1109,7 +1109,7 @@ public: {} 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) noexcept( @@ -1127,22 +1127,11 @@ public: } table(const table& x,const Allocator& al_): - hash_base{empty_init,x.h()},pred_base{empty_init,x.pred()}, - allocator_base{empty_init,al_},size_{0}, - arrays( - new_arrays(std::size_t(std::ceil(static_cast(x.size())/mlf)))), - ml{max_load()} + table{std::size_t(std::ceil(float(x.size())/mlf)),x.h(),x.pred(),al_} { - BOOST_TRY{ - x.for_all_elements([this](value_type* p){ - unchecked_insert(*p); - }); - } - BOOST_CATCH(...){ - destroy(); - BOOST_RETHROW - } - BOOST_CATCH_END + x.for_all_elements([this](value_type* p){ + unchecked_insert(*p); + }); } table(table&& x,const Allocator& al_): @@ -1178,7 +1167,10 @@ public: ~table()noexcept { - destroy(); + for_all_elements([this](value_type* p){ + destroy_element(p); + }); + delete_arrays(arrays); } table& operator=(const table& x) @@ -1467,14 +1459,6 @@ private: Allocator& al(){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) { return arrays_type::new_(al(),n);