diff --git a/boost/unordered/detail/buckets.hpp b/boost/unordered/detail/buckets.hpp index 85681a6..d9896f8 100644 --- a/boost/unordered/detail/buckets.hpp +++ b/boost/unordered/detail/buckets.hpp @@ -892,7 +892,16 @@ namespace boost { namespace unordered { namespace detail { { for(;;) { n = static_cast(n->next_); - if (n == end) return; + if (n == end) { + if (n) { + std::size_t new_bucket_index = + policy::to_bucket(bucket_count_, n->hash_); + if (bucket_index != new_bucket_index) { + get_bucket(new_bucket_index)->next_ = prev; + } + } + return; + } std::size_t new_bucket_index = policy::to_bucket(this->bucket_count_, n->hash_); diff --git a/boost/unordered/detail/equivalent.hpp b/boost/unordered/detail/equivalent.hpp index 5cbf6a7..4e6af45 100644 --- a/boost/unordered/detail/equivalent.hpp +++ b/boost/unordered/detail/equivalent.hpp @@ -722,9 +722,9 @@ namespace boost { namespace unordered { namespace detail { if(begin == group2) { link_pointer end1 = group1->group_prev_; - link_pointer end2 = group2->group_prev_; + link_pointer end2 = end->group_prev_; group1->group_prev_ = end2; - group2->group_prev_ = end1; + end->group_prev_ = end1; } } } @@ -851,7 +851,7 @@ namespace boost { namespace unordered { namespace detail { // strong otherwise exception safety void rehash_impl(std::size_t num_buckets) { - BOOST_ASSERT(this->size_); + BOOST_ASSERT(this->buckets_); buckets dst(this->node_alloc(), num_buckets); dst.create_buckets(); diff --git a/boost/unordered/detail/unique.hpp b/boost/unordered/detail/unique.hpp index 10db58f..0763b82 100644 --- a/boost/unordered/detail/unique.hpp +++ b/boost/unordered/detail/unique.hpp @@ -724,7 +724,7 @@ namespace boost { namespace unordered { namespace detail { // strong otherwise exception safety void rehash_impl(std::size_t num_buckets) { - BOOST_ASSERT(this->size_); + BOOST_ASSERT(this->buckets_); buckets dst(this->node_alloc(), num_buckets); dst.create_buckets();