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