mirror of
https://github.com/boostorg/container.git
synced 2025-08-01 13:34:30 +02:00
Fixes issue #93
This commit is contained in:
@@ -1263,6 +1263,7 @@ use [*Boost.Container]? There are several reasons for that:
|
||||
* [@https://github.com/boostorg/container/pull/86 GitHub #86: ['"Add missing warning re-enabling include"]].
|
||||
* [@https://github.com/boostorg/container/issues/89 GitHub #89: ['"UBSAN failures detected in preflight CI PR"]].
|
||||
* [@https://github.com/boostorg/container/issues/90 GitHub #90: ['"Build fails on clang-5 with libstdc++7-dev (C++17 issue)"]].
|
||||
* [@https://github.com/boostorg/container/issues/93 GitHub #93: ['"vector::erase memory leak"]].
|
||||
|
||||
[endsect]
|
||||
|
||||
|
@@ -2413,17 +2413,10 @@ class vector
|
||||
const bool propagate_alloc = allocator_traits_type::propagate_on_container_move_assignment::value;
|
||||
|
||||
const bool is_propagable_from_x = is_propagable_from(x_alloc, x.m_holder.start(), this_alloc, propagate_alloc);
|
||||
const bool is_propagable_from_t = is_propagable_from(this_alloc, m_holder.start(), x_alloc, propagate_alloc);
|
||||
const bool are_both_propagable = is_propagable_from_x && is_propagable_from_t;
|
||||
|
||||
//Resources can be transferred if both allocators are
|
||||
//going to be equal after this function (either propagated or already equal)
|
||||
if(are_both_propagable){
|
||||
//Destroy objects but retain memory in case x reuses it in the future
|
||||
this->clear();
|
||||
this->m_holder.swap_resources(x.m_holder);
|
||||
}
|
||||
else if(is_propagable_from_x){
|
||||
if(is_propagable_from_x){
|
||||
this->clear();
|
||||
if(BOOST_LIKELY(!!this->m_holder.m_start))
|
||||
this->m_holder.deallocate(this->m_holder.m_start, this->m_holder.m_capacity);
|
||||
|
Reference in New Issue
Block a user