diff --git a/doc/changes.qbk b/doc/changes.qbk index 30b465e3..d93a63ea 100644 --- a/doc/changes.qbk +++ b/doc/changes.qbk @@ -239,5 +239,8 @@ C++11 support has resulted in some breaking changes: * Avoid some warnings ([ticket 8851], [ticket 8874]). * Avoid exposing some detail functions via. ADL on the iterators. +* Follow the standard by only using the allocators' construct and destroy + methods to construct and destroy stored elements. Don't use them for internal + data like pointers. [endsect] diff --git a/include/boost/unordered/detail/allocate.hpp b/include/boost/unordered/detail/allocate.hpp index bca63e6a..4c20b168 100644 --- a/include/boost/unordered/detail/allocate.hpp +++ b/include/boost/unordered/detail/allocate.hpp @@ -1081,8 +1081,10 @@ namespace boost { namespace unordered { namespace detail { ~array_constructor() { if (ptr_) { - for(pointer p = ptr_; p != constructed_; ++p) - traits::destroy(alloc_, boost::addressof(*p)); + for(pointer p = ptr_; p != constructed_; ++p) { + boost::unordered::detail::func::destroy( + boost::addressof(*p)); + } traits::deallocate(alloc_, ptr_, length_); } @@ -1095,8 +1097,9 @@ namespace boost { namespace unordered { namespace detail { length_ = l; ptr_ = traits::allocate(alloc_, length_); pointer end = ptr_ + static_cast(length_); - for(constructed_ = ptr_; constructed_ != end; ++constructed_) - traits::construct(alloc_, boost::addressof(*constructed_), v); + for(constructed_ = ptr_; constructed_ != end; ++constructed_) { + new ((void*) boost::addressof(*constructed_)) V(v); + } } pointer get() const diff --git a/include/boost/unordered/detail/buckets.hpp b/include/boost/unordered/detail/buckets.hpp index 6ad3808b..fd038b7b 100644 --- a/include/boost/unordered/detail/buckets.hpp +++ b/include/boost/unordered/detail/buckets.hpp @@ -402,7 +402,7 @@ namespace boost { namespace unordered { namespace detail { } if (node_constructed_) { - node_allocator_traits::destroy(alloc_, + boost::unordered::detail::func::destroy( boost::addressof(*node_)); } @@ -419,8 +419,7 @@ namespace boost { namespace unordered { namespace detail { node_ = node_allocator_traits::allocate(alloc_, 1); - node_allocator_traits::construct(alloc_, - boost::addressof(*node_), node()); + new ((void*) boost::addressof(*node_)) node(); node_->init(node_); node_constructed_ = true; } @@ -548,7 +547,7 @@ namespace boost { namespace unordered { namespace detail { boost::unordered::detail::func::destroy_value_impl(this->alloc_, p->value_ptr()); - node_allocator_traits::destroy(this->alloc_, boost::addressof(*p)); + boost::unordered::detail::func::destroy(boost::addressof(*p)); node_allocator_traits::deallocate(this->alloc_, p, 1); } } diff --git a/include/boost/unordered/detail/table.hpp b/include/boost/unordered/detail/table.hpp index 65fb780c..7b4cc0ec 100644 --- a/include/boost/unordered/detail/table.hpp +++ b/include/boost/unordered/detail/table.hpp @@ -523,8 +523,7 @@ namespace boost { namespace unordered { namespace detail { boost::unordered::detail::func::destroy_value_impl(node_alloc(), n->value_ptr()); - node_allocator_traits::destroy(node_alloc(), - boost::addressof(*n)); + boost::unordered::detail::func::destroy(boost::addressof(*n)); node_allocator_traits::deallocate(node_alloc(), n, 1); --size_; } @@ -551,7 +550,7 @@ namespace boost { namespace unordered { namespace detail { if (bucket::extra_node) { node_pointer n = static_cast( get_bucket(bucket_count_)->next_); - node_allocator_traits::destroy(node_alloc(), + boost::unordered::detail::func::destroy( boost::addressof(*n)); node_allocator_traits::deallocate(node_alloc(), n, 1); } @@ -588,7 +587,7 @@ namespace boost { namespace unordered { namespace detail { bucket_pointer end = get_bucket(bucket_count_ + 1); for(bucket_pointer it = buckets_; it != end; ++it) { - bucket_allocator_traits::destroy(bucket_alloc(), + boost::unordered::detail::func::destroy( boost::addressof(*it)); }