From a46220986f95c01a2611750647d96d60a3df58fb Mon Sep 17 00:00:00 2001 From: Christian Mazakas Date: Tue, 31 Jan 2023 10:32:06 -0800 Subject: [PATCH] Replace usage of rote try-catch with corresponding Boost versions --- .../boost/unordered/unordered_node_map.hpp | 21 +++++++------------ .../boost/unordered/unordered_node_set.hpp | 10 ++++++--- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/include/boost/unordered/unordered_node_map.hpp b/include/boost/unordered/unordered_node_map.hpp index ca6f7046..bbda2300 100644 --- a/include/boost/unordered/unordered_node_map.hpp +++ b/include/boost/unordered/unordered_node_map.hpp @@ -86,31 +86,26 @@ namespace boost { template static void construct(A& al, element_type* p, element_type const& copy) { - p->p = boost::to_address(boost::allocator_allocate(al, 1)); - try { - boost::allocator_construct(al, p->p, *copy.p); - } catch (...) { - boost::allocator_deallocate(al, - boost::pointer_traits< - typename boost::allocator_pointer::type>::pointer_to(*p->p), - 1); - throw; - } + construct(al, p, *copy.p); } template static void construct(A& al, element_type* p, Args&&... args) { p->p = boost::to_address(boost::allocator_allocate(al, 1)); - try { + BOOST_TRY + { boost::allocator_construct(al, p->p, std::forward(args)...); - } catch (...) { + } + BOOST_CATCH(...) + { boost::allocator_deallocate(al, boost::pointer_traits< typename boost::allocator_pointer::type>::pointer_to(*p->p), 1); - throw; + BOOST_RETHROW } + BOOST_CATCH_END } template static void destroy(A& al, element_type* p) noexcept diff --git a/include/boost/unordered/unordered_node_set.hpp b/include/boost/unordered/unordered_node_set.hpp index 6733913c..01d26258 100644 --- a/include/boost/unordered/unordered_node_set.hpp +++ b/include/boost/unordered/unordered_node_set.hpp @@ -76,15 +76,19 @@ namespace boost { static void construct(A& al, element_type* p, Args&&... args) { p->p = boost::to_address(boost::allocator_allocate(al, 1)); - try { + BOOST_TRY + { boost::allocator_construct(al, p->p, std::forward(args)...); - } catch (...) { + } + BOOST_CATCH(...) + { boost::allocator_deallocate(al, boost::pointer_traits< typename boost::allocator_pointer::type>::pointer_to(*p->p), 1); - throw; + BOOST_RETHROW } + BOOST_CATCH_END } template static void destroy(A& al, element_type* p) noexcept