From c9340390b00be65aad99447bf817592a28810987 Mon Sep 17 00:00:00 2001 From: joaquintides Date: Tue, 18 Oct 2022 17:28:57 +0200 Subject: [PATCH] completed previous commit --- include/boost/unordered/detail/foa.hpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/include/boost/unordered/detail/foa.hpp b/include/boost/unordered/detail/foa.hpp index 827c22c2..114f94c5 100644 --- a/include/boost/unordered/detail/foa.hpp +++ b/include/boost/unordered/detail/foa.hpp @@ -1458,6 +1458,13 @@ private: alloc_traits::destroy(al(),p); } + struct destroy_on_exit + { + ~destroy_on_exit(){this_->destroy_element(p);} + table* this_; + value_type* p; + }; + std::size_t max_load()const { static constexpr std::size_t small_capacity=2*N-1; @@ -1688,9 +1695,10 @@ private: void nosize_transfer_element(value_type* p,const arrays_type& arrays_) { auto hash=hash_for(key_from(*p)); + destroy_on_exit d{this,p}; + (void)d; /* ununsed var warning */ nosize_unchecked_emplace_at( arrays_,position_for(hash,arrays_),hash,type_policy::move(*p)); - destroy_element(p); } template