From a91f6d317b97c6a142d04d813196abf39e168764 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Tue, 21 Jul 2015 23:40:52 +0200 Subject: [PATCH] Fixed wrong call to vector::merge_unique in insert_unique and used placement construction in priv_merge_in_new_buffer --- include/boost/container/detail/flat_tree.hpp | 2 +- include/boost/container/vector.hpp | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/include/boost/container/detail/flat_tree.hpp b/include/boost/container/detail/flat_tree.hpp index a68e7b2..f274211 100644 --- a/include/boost/container/detail/flat_tree.hpp +++ b/include/boost/container/detail/flat_tree.hpp @@ -506,7 +506,7 @@ class flat_tree >::type * = 0 #endif ) - { this->m_data.m_vect.merge_unique(first, last); } + { this->m_data.m_vect.merge_unique(first, last, value_compare()); } #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) diff --git a/include/boost/container/vector.hpp b/include/boost/container/vector.hpp index 341832b..1cf44c8 100644 --- a/include/boost/container/vector.hpp +++ b/include/boost/container/vector.hpp @@ -2292,7 +2292,7 @@ class vector //Merge in new buffer loop while(1){ if(!n) { - ::boost::container::uninitialized_move_alloc(this->m_holder.alloc(), pbeg, pend, d_first); + ::boost::container::uninitialized_move_alloc(this->m_holder.alloc(), pbeg, pend, d_first); break; } else if(pbeg == pend) { @@ -2300,8 +2300,9 @@ class vector break; } //maintain stability moving external values only if they are strictly less - else if(comp(*first, *pbeg)) { - *d_first = ::boost::move(*first); + else if(comp(*first, *pbeg)) { + allocator_traits_type::construct( this->m_holder.alloc(), d_first, ::boost::move(*first) ); + new_values_destroyer.increment_size(1u); ++first; --n; ++d_first; @@ -2312,7 +2313,8 @@ class vector --added; } else{ - *d_first = ::boost::move(*pbeg); + allocator_traits_type::construct( this->m_holder.alloc(), d_first, ::boost::move(*pbeg) ); + new_values_destroyer.increment_size(1u); ++pbeg; ++d_first; }