mirror of
https://github.com/boostorg/container.git
synced 2025-07-30 12:37:17 +02:00
Fixes #295 ("Bug in small_vector::swap")
This commit is contained in:
@ -1430,6 +1430,7 @@ use [*Boost.Container]? There are several reasons for that:
|
||||
* Fixed bugs/issues:
|
||||
* [@https://github.com/boostorg/container/issues/261 GitHub #261: ['"End iterators are not dereferencable"]].
|
||||
* [@https://github.com/boostorg/container/issues/288 GitHub #288: ['"Compile error when using flat_map::extract_sequence with small_vector"]].
|
||||
* [@https://github.com/boostorg/container/issues/295 GitHub #295: ['"Bug in small_vector::swap"]].
|
||||
|
||||
[endsect]
|
||||
|
||||
|
@ -2765,7 +2765,7 @@ private:
|
||||
//Move internal memory data to the internal memory data of the target, this can throw
|
||||
BOOST_ASSERT(extmem.capacity() >= intmem.size());
|
||||
::boost::container::uninitialized_move_alloc_n
|
||||
(intmem.get_stored_allocator(), this->priv_raw_begin(), intmem.size(), extmem.priv_raw_begin());
|
||||
(intmem.get_stored_allocator(), intmem.priv_raw_begin(), intmem.size(), extmem.priv_raw_begin());
|
||||
|
||||
//Exception not thrown, commit new state
|
||||
extmem.m_holder.set_stored_size(intmem.size());
|
||||
@ -2776,7 +2776,7 @@ private:
|
||||
|
||||
//Destroy moved elements from intmem
|
||||
boost::container::destroy_alloc_n
|
||||
( intmem.get_stored_allocator(), this->priv_raw_begin()
|
||||
( intmem.get_stored_allocator(), intmem.priv_raw_begin()
|
||||
, intmem.size());
|
||||
|
||||
//Adopt dynamic buffer
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2004-2013. Distributed under the Boost
|
||||
@ -297,10 +298,10 @@ bool test_swap()
|
||||
v.push_back(int(i));
|
||||
}
|
||||
vec w;
|
||||
const std::size_t v_size = v.size();
|
||||
const std::size_t w_size = w.size();
|
||||
vec v_copy = v;
|
||||
vec w_copy = w;
|
||||
v.swap(w);
|
||||
if(v.size() != w_size || w.size() != v_size)
|
||||
if (w != v_copy || v != w_copy)
|
||||
return false;
|
||||
}
|
||||
{ //v smaller than static capacity, w empty
|
||||
@ -309,10 +310,10 @@ bool test_swap()
|
||||
v.push_back(int(i));
|
||||
}
|
||||
vec w;
|
||||
const std::size_t v_size = v.size();
|
||||
const std::size_t w_size = w.size();
|
||||
vec v_copy = v;
|
||||
vec w_copy = w;
|
||||
v.swap(w);
|
||||
if(v.size() != w_size || w.size() != v_size)
|
||||
if (w != v_copy || v != w_copy)
|
||||
return false;
|
||||
}
|
||||
{ //v bigger than static capacity, w enough capacity for static
|
||||
@ -324,10 +325,10 @@ bool test_swap()
|
||||
for (std::size_t i = 0, max = w.capacity() / 2; i != max; ++i) {
|
||||
w.push_back(int(i));
|
||||
}
|
||||
const std::size_t v_size = v.size();
|
||||
const std::size_t w_size = w.size();
|
||||
vec v_copy = v;
|
||||
vec w_copy = w;
|
||||
v.swap(w);
|
||||
if (v.size() != w_size || w.size() != v_size)
|
||||
if (w != v_copy || v != w_copy)
|
||||
return false;
|
||||
}
|
||||
{ //v & w smaller than static capacity
|
||||
@ -339,10 +340,10 @@ bool test_swap()
|
||||
for(std::size_t i = 0, max = w.capacity()/2; i != max; ++i){
|
||||
w.push_back(int(i));
|
||||
}
|
||||
const std::size_t v_size = v.size();
|
||||
const std::size_t w_size = w.size();
|
||||
vec v_copy = v;
|
||||
vec w_copy = w;
|
||||
v.swap(w);
|
||||
if(v.size() != w_size || w.size() != v_size)
|
||||
if (w != v_copy || v != w_copy)
|
||||
return false;
|
||||
}
|
||||
{ //v & w bigger than static capacity
|
||||
@ -354,10 +355,10 @@ bool test_swap()
|
||||
for(std::size_t i = 0, max = w.capacity()*2; i != max; ++i){
|
||||
w.push_back(int(i));
|
||||
}
|
||||
const std::size_t v_size = v.size();
|
||||
const std::size_t w_size = w.size();
|
||||
vec v_copy = v;
|
||||
vec w_copy = w;
|
||||
v.swap(w);
|
||||
if(v.size() != w_size || w.size() != v_size)
|
||||
if (w != v_copy || v != w_copy)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user