forked from boostorg/unordered
Don't use allocator to construct/destroy anything other than elements.
As specified in 23.2.1.3.
This commit is contained in:
@ -239,5 +239,8 @@ C++11 support has resulted in some breaking changes:
|
|||||||
|
|
||||||
* Avoid some warnings ([ticket 8851], [ticket 8874]).
|
* Avoid some warnings ([ticket 8851], [ticket 8874]).
|
||||||
* Avoid exposing some detail functions via. ADL on the iterators.
|
* 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]
|
[endsect]
|
||||||
|
@ -1081,8 +1081,10 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
|
|
||||||
~array_constructor() {
|
~array_constructor() {
|
||||||
if (ptr_) {
|
if (ptr_) {
|
||||||
for(pointer p = ptr_; p != constructed_; ++p)
|
for(pointer p = ptr_; p != constructed_; ++p) {
|
||||||
traits::destroy(alloc_, boost::addressof(*p));
|
boost::unordered::detail::func::destroy(
|
||||||
|
boost::addressof(*p));
|
||||||
|
}
|
||||||
|
|
||||||
traits::deallocate(alloc_, ptr_, length_);
|
traits::deallocate(alloc_, ptr_, length_);
|
||||||
}
|
}
|
||||||
@ -1095,8 +1097,9 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
length_ = l;
|
length_ = l;
|
||||||
ptr_ = traits::allocate(alloc_, length_);
|
ptr_ = traits::allocate(alloc_, length_);
|
||||||
pointer end = ptr_ + static_cast<std::ptrdiff_t>(length_);
|
pointer end = ptr_ + static_cast<std::ptrdiff_t>(length_);
|
||||||
for(constructed_ = ptr_; constructed_ != end; ++constructed_)
|
for(constructed_ = ptr_; constructed_ != end; ++constructed_) {
|
||||||
traits::construct(alloc_, boost::addressof(*constructed_), v);
|
new ((void*) boost::addressof(*constructed_)) V(v);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pointer get() const
|
pointer get() const
|
||||||
|
@ -402,7 +402,7 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (node_constructed_) {
|
if (node_constructed_) {
|
||||||
node_allocator_traits::destroy(alloc_,
|
boost::unordered::detail::func::destroy(
|
||||||
boost::addressof(*node_));
|
boost::addressof(*node_));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -419,8 +419,7 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
|
|
||||||
node_ = node_allocator_traits::allocate(alloc_, 1);
|
node_ = node_allocator_traits::allocate(alloc_, 1);
|
||||||
|
|
||||||
node_allocator_traits::construct(alloc_,
|
new ((void*) boost::addressof(*node_)) node();
|
||||||
boost::addressof(*node_), node());
|
|
||||||
node_->init(node_);
|
node_->init(node_);
|
||||||
node_constructed_ = true;
|
node_constructed_ = true;
|
||||||
}
|
}
|
||||||
@ -548,7 +547,7 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
|
|
||||||
boost::unordered::detail::func::destroy_value_impl(this->alloc_,
|
boost::unordered::detail::func::destroy_value_impl(this->alloc_,
|
||||||
p->value_ptr());
|
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);
|
node_allocator_traits::deallocate(this->alloc_, p, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -523,8 +523,7 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
|
|
||||||
boost::unordered::detail::func::destroy_value_impl(node_alloc(),
|
boost::unordered::detail::func::destroy_value_impl(node_alloc(),
|
||||||
n->value_ptr());
|
n->value_ptr());
|
||||||
node_allocator_traits::destroy(node_alloc(),
|
boost::unordered::detail::func::destroy(boost::addressof(*n));
|
||||||
boost::addressof(*n));
|
|
||||||
node_allocator_traits::deallocate(node_alloc(), n, 1);
|
node_allocator_traits::deallocate(node_alloc(), n, 1);
|
||||||
--size_;
|
--size_;
|
||||||
}
|
}
|
||||||
@ -551,7 +550,7 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
if (bucket::extra_node) {
|
if (bucket::extra_node) {
|
||||||
node_pointer n = static_cast<node_pointer>(
|
node_pointer n = static_cast<node_pointer>(
|
||||||
get_bucket(bucket_count_)->next_);
|
get_bucket(bucket_count_)->next_);
|
||||||
node_allocator_traits::destroy(node_alloc(),
|
boost::unordered::detail::func::destroy(
|
||||||
boost::addressof(*n));
|
boost::addressof(*n));
|
||||||
node_allocator_traits::deallocate(node_alloc(), n, 1);
|
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);
|
bucket_pointer end = get_bucket(bucket_count_ + 1);
|
||||||
for(bucket_pointer it = buckets_; it != end; ++it)
|
for(bucket_pointer it = buckets_; it != end; ++it)
|
||||||
{
|
{
|
||||||
bucket_allocator_traits::destroy(bucket_alloc(),
|
boost::unordered::detail::func::destroy(
|
||||||
boost::addressof(*it));
|
boost::addressof(*it));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user