diff --git a/include/boost/unordered/detail/implementation.hpp b/include/boost/unordered/detail/implementation.hpp index 38eaa6a5..09baab65 100644 --- a/include/boost/unordered/detail/implementation.hpp +++ b/include/boost/unordered/detail/implementation.hpp @@ -1262,19 +1262,11 @@ namespace func { #if BOOST_UNORDERED_CXX11_CONSTRUCTION -template -inline void call_construct( - Alloc& alloc, T* address, BOOST_FWD_REF(Args)... args) -{ - boost::unordered::detail::allocator_traits::construct( - alloc, address, boost::forward(args)...); -} - -template -inline void call_destroy(Alloc& alloc, T* x) -{ - boost::unordered::detail::allocator_traits::destroy(alloc, x); -} +#define BOOST_UNORDERED_CALL_CONSTRUCT0(Traits, alloc, address) \ + Traits::construct(alloc, address) +#define BOOST_UNORDERED_CALL_CONSTRUCT1(Traits, alloc, address, a0) \ + Traits::construct(alloc, address, a0) +#define BOOST_UNORDERED_CALL_DESTROY(Traits, alloc, x) Traits::destroy(alloc, x) #elif !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) @@ -1284,10 +1276,12 @@ inline void call_construct(Alloc&, T* address, BOOST_FWD_REF(Args)... args) new ((void*)address) T(boost::forward(args)...); } -template inline void call_destroy(Alloc&, T* x) -{ - boost::unordered::detail::func::destroy(x); -} +#define BOOST_UNORDERED_CALL_CONSTRUCT0(Traits, alloc, address) \ + boost::unordered::detail::func::call_construct(alloc, address) +#define BOOST_UNORDERED_CALL_CONSTRUCT1(Traits, alloc, address, a0) \ + boost::unordered::detail::func::call_construct(alloc, address, a0) +#define BOOST_UNORDERED_CALL_DESTROY(Traits, alloc, x) \ + boost::unordered::detail::func::destroy(x) #else @@ -1303,10 +1297,12 @@ inline void call_construct(Alloc&, T* address, BOOST_FWD_REF(A0) a0) new ((void*)address) T(boost::forward(a0)); } -template inline void call_destroy(Alloc&, T* x) -{ - boost::unordered::detail::func::destroy(x); -} +#define BOOST_UNORDERED_CALL_CONSTRUCT0(Traits, alloc, address) \ + boost::unordered::detail::func::call_construct(alloc, address) +#define BOOST_UNORDERED_CALL_CONSTRUCT1(Traits, alloc, address, a0) \ + boost::unordered::detail::func::call_construct(alloc, address, a0) +#define BOOST_UNORDERED_CALL_DESTROY(Traits, alloc, x) \ + boost::unordered::detail::func::destroy(x) #endif @@ -1650,8 +1646,8 @@ template struct node_constructor BOOST_ASSERT(!node_); node_ = p; node_constructed_ = true; - boost::unordered::detail::func::call_destroy( - alloc_, node_->value_ptr()); + BOOST_UNORDERED_CALL_DESTROY( + node_allocator_traits, alloc_, node_->value_ptr()); } private: @@ -1707,8 +1703,8 @@ template struct node_tmp template node_tmp::~node_tmp() { if (node_) { - boost::unordered::detail::func::call_destroy( - alloc_, node_->value_ptr()); + BOOST_UNORDERED_CALL_DESTROY( + node_allocator_traits, alloc_, node_->value_ptr()); boost::unordered::detail::func::destroy(boost::addressof(*node_)); node_allocator_traits::deallocate(alloc_, node_, 1); } @@ -1742,8 +1738,9 @@ construct_node(Alloc& alloc, BOOST_FWD_REF(U) x) { node_constructor a(alloc); a.create_node(); - boost::unordered::detail::func::call_construct( - alloc, a.node_->value_ptr(), boost::forward(x)); + BOOST_UNORDERED_CALL_CONSTRUCT1( + boost::unordered::detail::allocator_traits, alloc, + a.node_->value_ptr(), boost::forward(x)); return a.release(); } @@ -2183,7 +2180,7 @@ template struct node_holder } else { constructor_.create_node(); } - boost::unordered::detail::func::call_construct( + BOOST_UNORDERED_CALL_CONSTRUCT1(node_allocator_traits, constructor_.alloc_, constructor_.node_->value_ptr(), v); return constructor_.release(); } @@ -2195,8 +2192,9 @@ template struct node_holder } else { constructor_.create_node(); } - boost::unordered::detail::func::call_construct(constructor_.alloc_, - constructor_.node_->value_ptr(), boost::move(v)); + BOOST_UNORDERED_CALL_CONSTRUCT1(node_allocator_traits, + constructor_.alloc_, constructor_.node_->value_ptr(), + boost::move(v)); return constructor_.release(); } @@ -2209,8 +2207,8 @@ template node_holder::~node_holder() node_pointer p = nodes_; nodes_ = static_cast(p->next_); - boost::unordered::detail::func::call_destroy( - constructor_.alloc_, p->value_ptr()); + BOOST_UNORDERED_CALL_DESTROY( + node_allocator_traits, constructor_.alloc_, p->value_ptr()); boost::unordered::detail::func::destroy(boost::addressof(*p)); node_allocator_traits::deallocate(constructor_.alloc_, p, 1); } @@ -2900,15 +2898,15 @@ struct table : boost::unordered::detail::functions(new_count); for (; constructed != end; ++constructed) { - boost::unordered::detail::func::call_construct( + BOOST_UNORDERED_CALL_CONSTRUCT0(bucket_allocator_traits, bucket_alloc(), boost::addressof(*constructed)); } if (buckets_) { // Copy the nodes to the new buckets, including the dummy // node if there is one. - boost::unordered::detail::func::call_construct(bucket_alloc(), - boost::addressof(*constructed), + BOOST_UNORDERED_CALL_CONSTRUCT1(bucket_allocator_traits, + bucket_alloc(), boost::addressof(*constructed), (buckets_ + static_cast(bucket_count_)) ->next_); ++constructed; @@ -2917,11 +2915,12 @@ struct table : boost::unordered::detail::functions(prev->next_); prev->next_ = n->next_; - boost::unordered::detail::func::call_destroy( - node_alloc(), n->value_ptr()); + BOOST_UNORDERED_CALL_DESTROY( + node_allocator_traits, node_alloc(), n->value_ptr()); boost::unordered::detail::func::destroy(boost::addressof(*n)); node_allocator_traits::deallocate(node_alloc(), n, 1); --size_; @@ -3065,8 +3064,8 @@ struct table : boost::unordered::detail::functions if (!a.node_) { a.create_node(); } - boost::unordered::detail::func::call_construct( - a.alloc_, a.node_->value_ptr(), *i); + BOOST_UNORDERED_CALL_CONSTRUCT1( + node_allocator_traits, a.alloc_, a.node_->value_ptr(), *i); node_tmp b(a.release(), a.alloc_); const_key_type& k = this->get_key(b.node_);