From bdfe294e61ff9442495a56c89d1050cdbab8601f Mon Sep 17 00:00:00 2001 From: Christian Mazakas Date: Mon, 3 Oct 2022 14:47:41 -0700 Subject: [PATCH] Add temporary polyfill for foa table's assignment operator so that the definition of the allocator copy-assignment operator isn't required --- include/boost/unordered/detail/foa.hpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/include/boost/unordered/detail/foa.hpp b/include/boost/unordered/detail/foa.hpp index 7f3b7dde..1ea4b3e0 100644 --- a/include/boost/unordered/detail/foa.hpp +++ b/include/boost/unordered/detail/foa.hpp @@ -975,16 +975,31 @@ public: delete_arrays(arrays); } + template + typename std::enable_if< + !AllocTraits::propagate_on_container_copy_assignment::value, + void + >::type + copy_assign_helper(const table&) {} + + template + typename std::enable_if< + AllocTraits::propagate_on_container_copy_assignment::value, + void + >::type + copy_assign_helper(const table& x) + { + if(al()!=x.al())reserve(0); + al()=x.al(); + } + table& operator=(const table& x) { if(this!=&x){ clear(); h()=x.h(); pred()=x.pred(); - if(alloc_traits::propagate_on_container_copy_assignment::value){ - if(al()!=x.al())reserve(0); - al()=x.al(); - } + copy_assign_helper(x); // TODO may shrink arrays and miss an opportunity for memory reuse reserve(x.size()); x.for_all_elements([this](value_type* p){