From 48e92afd9209a780d37a2b55083658b7391ee065 Mon Sep 17 00:00:00 2001 From: Christian Mazakas Date: Thu, 2 Mar 2023 15:55:56 -0800 Subject: [PATCH] Refactor drop_guard into destroy_on_exit --- include/boost/unordered/detail/foa.hpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/include/boost/unordered/detail/foa.hpp b/include/boost/unordered/detail/foa.hpp index 684aefdd..b7c7d8b3 100644 --- a/include/boost/unordered/detail/foa.hpp +++ b/include/boost/unordered/detail/foa.hpp @@ -1137,17 +1137,6 @@ union uninitialized_storage ~uninitialized_storage(){} }; -template -struct drop_guard -{ - using type_policy=TypePolicy; - - A& a; - T* p; - ~drop_guard(){type_policy::destroy(a,p);}; -}; - - /* foa::table interface departs in a number of ways from that of C++ unordered * associative containers because it's not for end-user consumption * (boost::unordered_[flat|node]_[map|set]) wrappers complete it as @@ -1454,7 +1443,7 @@ public: type_policy::construct(al(),p,std::forward(args)...); - drop_guard guard{al(),p}; + destroy_on_exit guard{al(),p}; return emplace_impl(type_policy::move(*p)); } @@ -1658,6 +1647,16 @@ private: bool rollback_=false; }; + template + struct destroy_on_exit + { + using type_policy=TypePolicy; + + Allocator &a; + T *p; + ~destroy_on_exit(){type_policy::destroy(a,p);}; + }; + Hash& h(){return hash_base::get();} const Hash& h()const{return hash_base::get();} Pred& pred(){return pred_base::get();}