From cd57bf5000283b97367beac4aa4f51ac990ea774 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sat, 25 Aug 2012 21:53:25 +0000 Subject: [PATCH] Unordered: And use allocator traits to destroy values. [SVN r80222] --- include/boost/unordered/detail/allocate.hpp | 19 +++++++++++++++++++ include/boost/unordered/detail/buckets.hpp | 9 ++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/include/boost/unordered/detail/allocate.hpp b/include/boost/unordered/detail/allocate.hpp index 7a0e28a1..f48c7a8f 100644 --- a/include/boost/unordered/detail/allocate.hpp +++ b/include/boost/unordered/detail/allocate.hpp @@ -775,6 +775,12 @@ namespace boost { namespace unordered { namespace detail { address, boost::forward(args)...); } + template + inline void destroy_impl(Alloc& alloc, T* x) { + boost::unordered::detail::allocator_traits::destroy(alloc, x); + } + + # else template @@ -784,8 +790,21 @@ namespace boost { namespace unordered { namespace detail { new((void*) address) T(boost::forward(args)...); } + template + inline void destroy_impl(Alloc&, T* x) { + boost::unordered::detail::destroy(x); + } + + # endif +#else + + template + inline void destroy_impl(Alloc&, T* x) { + boost::unordered::detail::destroy(x); + } + #endif //////////////////////////////////////////////////////////////////////////// diff --git a/include/boost/unordered/detail/buckets.hpp b/include/boost/unordered/detail/buckets.hpp index 3fd6f910..941d441d 100644 --- a/include/boost/unordered/detail/buckets.hpp +++ b/include/boost/unordered/detail/buckets.hpp @@ -112,7 +112,8 @@ namespace boost { namespace unordered { namespace detail { { if (node_) { if (value_constructed_) { - boost::unordered::detail::destroy(node_->value_ptr()); + boost::unordered::detail::destroy_impl(alloc_, + node_->value_ptr()); } if (node_constructed_) { @@ -143,7 +144,8 @@ namespace boost { namespace unordered { namespace detail { if (value_constructed_) { - boost::unordered::detail::destroy(node_->value_ptr()); + boost::unordered::detail::destroy_impl(alloc_, + node_->value_ptr()); value_constructed_ = false; } } @@ -762,7 +764,8 @@ namespace boost { namespace unordered { namespace detail { inline void delete_node(c_iterator n) { - boost::unordered::detail::destroy(n.node_->value_ptr()); + boost::unordered::detail::destroy_impl(node_alloc(), + n.node_->value_ptr()); node_allocator_traits::destroy(node_alloc(), boost::addressof(*n.node_)); node_allocator_traits::deallocate(node_alloc(), n.node_, 1);