mirror of
https://github.com/boostorg/unordered.git
synced 2025-07-30 11:27:15 +02:00
Stop using allocators to construct/destroy internal types
The standard doesn't allow it. I should have known that.
This commit is contained in:
@ -1674,8 +1674,7 @@ template <typename Alloc> node_constructor<Alloc>::~node_constructor()
|
|||||||
{
|
{
|
||||||
if (node_) {
|
if (node_) {
|
||||||
if (node_constructed_) {
|
if (node_constructed_) {
|
||||||
BOOST_UNORDERED_CALL_DESTROY(
|
boost::unordered::detail::func::destroy(boost::addressof(*node_));
|
||||||
node_allocator_traits, alloc_, boost::addressof(*node_));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
node_allocator_traits::deallocate(alloc_, node_, 1);
|
node_allocator_traits::deallocate(alloc_, node_, 1);
|
||||||
@ -1689,8 +1688,7 @@ template <typename Alloc> void node_constructor<Alloc>::create_node()
|
|||||||
|
|
||||||
node_ = node_allocator_traits::allocate(alloc_, 1);
|
node_ = node_allocator_traits::allocate(alloc_, 1);
|
||||||
|
|
||||||
BOOST_UNORDERED_CALL_CONSTRUCT0(
|
new (boost::addressof(*node_)) node();
|
||||||
node_allocator_traits, alloc_, boost::addressof(*node_));
|
|
||||||
node_constructed_ = true;
|
node_constructed_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1721,8 +1719,7 @@ template <typename Alloc> node_tmp<Alloc>::~node_tmp()
|
|||||||
if (node_) {
|
if (node_) {
|
||||||
BOOST_UNORDERED_CALL_DESTROY(
|
BOOST_UNORDERED_CALL_DESTROY(
|
||||||
node_allocator_traits, alloc_, node_->value_ptr());
|
node_allocator_traits, alloc_, node_->value_ptr());
|
||||||
BOOST_UNORDERED_CALL_DESTROY(
|
boost::unordered::detail::func::destroy(boost::addressof(*node_));
|
||||||
node_allocator_traits, alloc_, boost::addressof(*node_));
|
|
||||||
node_allocator_traits::deallocate(alloc_, node_, 1);
|
node_allocator_traits::deallocate(alloc_, node_, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2221,8 +2218,7 @@ template <typename Alloc> node_holder<Alloc>::~node_holder()
|
|||||||
|
|
||||||
BOOST_UNORDERED_CALL_DESTROY(
|
BOOST_UNORDERED_CALL_DESTROY(
|
||||||
node_allocator_traits, constructor_.alloc_, p->value_ptr());
|
node_allocator_traits, constructor_.alloc_, p->value_ptr());
|
||||||
BOOST_UNORDERED_CALL_DESTROY(
|
boost::unordered::detail::func::destroy(boost::addressof(*p));
|
||||||
node_allocator_traits, constructor_.alloc_, boost::addressof(*p));
|
|
||||||
node_allocator_traits::deallocate(constructor_.alloc_, p, 1);
|
node_allocator_traits::deallocate(constructor_.alloc_, p, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2913,20 +2909,21 @@ struct table : boost::unordered::detail::functions<typename Types::hasher,
|
|||||||
bucket_allocator_traits::allocate(bucket_alloc(), length);
|
bucket_allocator_traits::allocate(bucket_alloc(), length);
|
||||||
bucket_pointer constructed = new_buckets;
|
bucket_pointer constructed = new_buckets;
|
||||||
|
|
||||||
|
// TODO: Apart from constructing the dummy node this is now
|
||||||
|
// nothrow, so maybe rearrange it a bit so that less
|
||||||
|
// exception handling is required.
|
||||||
BOOST_TRY
|
BOOST_TRY
|
||||||
{
|
{
|
||||||
bucket_pointer end =
|
bucket_pointer end =
|
||||||
new_buckets + static_cast<std::ptrdiff_t>(new_count);
|
new_buckets + static_cast<std::ptrdiff_t>(new_count);
|
||||||
for (; constructed != end; ++constructed) {
|
for (; constructed != end; ++constructed) {
|
||||||
BOOST_UNORDERED_CALL_CONSTRUCT0(bucket_allocator_traits,
|
new (boost::addressof(*constructed)) bucket();
|
||||||
bucket_alloc(), boost::addressof(*constructed));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buckets_) {
|
if (buckets_) {
|
||||||
// Copy the nodes to the new buckets, including the dummy
|
// Copy the nodes to the new buckets, including the dummy
|
||||||
// node if there is one.
|
// node if there is one.
|
||||||
BOOST_UNORDERED_CALL_CONSTRUCT1(bucket_allocator_traits,
|
new (boost::addressof(*constructed)) bucket(
|
||||||
bucket_alloc(), boost::addressof(*constructed),
|
|
||||||
(buckets_ + static_cast<std::ptrdiff_t>(bucket_count_))
|
(buckets_ + static_cast<std::ptrdiff_t>(bucket_count_))
|
||||||
->next_);
|
->next_);
|
||||||
++constructed;
|
++constructed;
|
||||||
@ -2935,21 +2932,17 @@ struct table : boost::unordered::detail::functions<typename Types::hasher,
|
|||||||
node_constructor a(node_alloc());
|
node_constructor a(node_alloc());
|
||||||
a.create_node();
|
a.create_node();
|
||||||
|
|
||||||
BOOST_UNORDERED_CALL_CONSTRUCT1(bucket_allocator_traits,
|
new (boost::addressof(*constructed)) bucket(a.release());
|
||||||
bucket_alloc(), boost::addressof(*constructed),
|
|
||||||
a.release());
|
|
||||||
++constructed;
|
++constructed;
|
||||||
} else {
|
} else {
|
||||||
BOOST_UNORDERED_CALL_CONSTRUCT0(bucket_allocator_traits,
|
new (boost::addressof(*constructed)) bucket();
|
||||||
bucket_alloc(), boost::addressof(*constructed));
|
|
||||||
++constructed;
|
++constructed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BOOST_CATCH(...)
|
BOOST_CATCH(...)
|
||||||
{
|
{
|
||||||
for (bucket_pointer p = new_buckets; p != constructed; ++p) {
|
for (bucket_pointer p = new_buckets; p != constructed; ++p) {
|
||||||
BOOST_UNORDERED_CALL_DESTROY(bucket_allocator_traits,
|
boost::unordered::detail::func::destroy(boost::addressof(*p));
|
||||||
bucket_alloc(), boost::addressof(*p));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bucket_allocator_traits::deallocate(
|
bucket_allocator_traits::deallocate(
|
||||||
@ -3030,8 +3023,7 @@ struct table : boost::unordered::detail::functions<typename Types::hasher,
|
|||||||
|
|
||||||
BOOST_UNORDERED_CALL_DESTROY(
|
BOOST_UNORDERED_CALL_DESTROY(
|
||||||
node_allocator_traits, node_alloc(), n->value_ptr());
|
node_allocator_traits, node_alloc(), n->value_ptr());
|
||||||
BOOST_UNORDERED_CALL_DESTROY(
|
boost::unordered::detail::func::destroy(boost::addressof(*n));
|
||||||
node_allocator_traits, node_alloc(), boost::addressof(*n));
|
|
||||||
node_allocator_traits::deallocate(node_alloc(), n, 1);
|
node_allocator_traits::deallocate(node_alloc(), n, 1);
|
||||||
--size_;
|
--size_;
|
||||||
}
|
}
|
||||||
@ -3059,8 +3051,7 @@ struct table : boost::unordered::detail::functions<typename Types::hasher,
|
|||||||
if (bucket::extra_node) {
|
if (bucket::extra_node) {
|
||||||
node_pointer n =
|
node_pointer n =
|
||||||
static_cast<node_pointer>(get_bucket(bucket_count_)->next_);
|
static_cast<node_pointer>(get_bucket(bucket_count_)->next_);
|
||||||
BOOST_UNORDERED_CALL_DESTROY(
|
boost::unordered::detail::func::destroy(boost::addressof(*n));
|
||||||
node_allocator_traits, node_alloc(), boost::addressof(*n));
|
|
||||||
node_allocator_traits::deallocate(node_alloc(), n, 1);
|
node_allocator_traits::deallocate(node_alloc(), n, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3076,8 +3067,7 @@ struct table : boost::unordered::detail::functions<typename Types::hasher,
|
|||||||
{
|
{
|
||||||
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) {
|
||||||
BOOST_UNORDERED_CALL_DESTROY(
|
boost::unordered::detail::func::destroy(boost::addressof(*it));
|
||||||
bucket_allocator_traits, bucket_alloc(), boost::addressof(*it));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bucket_allocator_traits::deallocate(
|
bucket_allocator_traits::deallocate(
|
||||||
|
Reference in New Issue
Block a user