mirror of
https://github.com/boostorg/container.git
synced 2025-08-02 22:14:26 +02:00
Fix move constructors with unequal allocators and move/copy assignment of tree.
This commit is contained in:
@@ -718,7 +718,8 @@ class deque : protected deque_base<Allocator>
|
||||
if(x.size()){
|
||||
this->priv_initialize_map(x.size());
|
||||
boost::container::uninitialized_copy_alloc
|
||||
(this->alloc(), x.begin(), x.end(), this->members_.m_start);
|
||||
( this->alloc(), boost::make_move_iterator(x.begin())
|
||||
, boost::make_move_iterator(x.end()), this->members_.m_start);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -370,7 +370,7 @@ struct node_alloc_holder
|
||||
protected:
|
||||
struct cloner
|
||||
{
|
||||
cloner(node_alloc_holder &holder)
|
||||
explicit cloner(node_alloc_holder &holder)
|
||||
: m_holder(holder)
|
||||
{}
|
||||
|
||||
@@ -380,6 +380,18 @@ struct node_alloc_holder
|
||||
node_alloc_holder &m_holder;
|
||||
};
|
||||
|
||||
struct move_cloner
|
||||
{
|
||||
move_cloner(node_alloc_holder &holder)
|
||||
: m_holder(holder)
|
||||
{}
|
||||
|
||||
NodePtr operator()(Node &other)
|
||||
{ return m_holder.create_node(::boost::move(other.get_data())); }
|
||||
|
||||
node_alloc_holder &m_holder;
|
||||
};
|
||||
|
||||
struct members_holder
|
||||
: public NodeAlloc
|
||||
{
|
||||
|
@@ -400,10 +400,10 @@ class RecyclingCloner
|
||||
{}
|
||||
|
||||
static void do_assign(node_ptr_type &p, const node_type &other, bool_<true>)
|
||||
{ p->do_assign(other.m_data); }
|
||||
{ p->do_move_assign(const_cast<node_type &>(other).m_data); }
|
||||
|
||||
static void do_assign(node_ptr_type &p, const node_type &other, bool_<false>)
|
||||
{ p->do_move_assign(const_cast<node_type &>(other).m_data); }
|
||||
{ p->do_assign(other.m_data); }
|
||||
|
||||
node_ptr_type operator()(const node_type &other) const
|
||||
{
|
||||
@@ -663,7 +663,7 @@ class tree
|
||||
}
|
||||
else{
|
||||
this->icont().clone_from
|
||||
(x.icont(), typename AllocHolder::cloner(*this), Destroyer(this->node_alloc()));
|
||||
(x.icont(), typename AllocHolder::move_cloner(*this), Destroyer(this->node_alloc()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -278,7 +278,7 @@ class list
|
||||
this->icont().swap(x.icont());
|
||||
}
|
||||
else{
|
||||
this->insert(this->cbegin(), x.begin(), x.end());
|
||||
this->insert(this->cbegin(), boost::make_move_iterator(x.begin()), boost::make_move_iterator(x.end()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1449,5 +1449,5 @@ namespace container {
|
||||
|
||||
#include <boost/container/detail/config_end.hpp>
|
||||
|
||||
#endif /* BOOST_CONTAINER_MAP_HPP */
|
||||
#endif // BOOST_CONTAINER_MAP_HPP
|
||||
|
||||
|
@@ -1154,5 +1154,4 @@ namespace container {
|
||||
|
||||
#include <boost/container/detail/config_end.hpp>
|
||||
|
||||
#endif /* BOOST_CONTAINER_SET_HPP */
|
||||
|
||||
#endif // BOOST_CONTAINER_SET_HPP
|
||||
|
@@ -331,7 +331,7 @@ class slist
|
||||
this->icont().swap(x.icont());
|
||||
}
|
||||
else{
|
||||
this->insert_after(this->cbefore_begin(), x.begin(), x.end());
|
||||
this->insert_after(this->cbefore_begin(), boost::make_move_iterator(x.begin()), boost::make_move_iterator(x.end()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1667,11 +1667,6 @@ namespace container {
|
||||
#define BOOST_CONTAINER_CLANG_INLINE_STD_NS
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wc++11-extensions"
|
||||
#define BOOST_CONTAINER_STD_NS_BEG _LIBCPP_BEGIN_NAMESPACE_STD
|
||||
#define BOOST_CONTAINER_STD_NS_END _LIBCPP_END_NAMESPACE_STD
|
||||
#else
|
||||
#define BOOST_CONTAINER_STD_NS_BEG namespace std{
|
||||
#define BOOST_CONTAINER_STD_NS_END }
|
||||
#endif
|
||||
|
||||
BOOST_CONTAINER_STD_NS_BEG
|
||||
|
@@ -728,11 +728,12 @@ class stable_vector
|
||||
: internal_data(a), index(a)
|
||||
{
|
||||
if(this->priv_node_alloc() == x.priv_node_alloc()){
|
||||
this->index.swap(x.index);
|
||||
this->priv_swap_members(x);
|
||||
}
|
||||
else{
|
||||
stable_vector_detail::clear_on_destroy<stable_vector> cod(*this);
|
||||
this->insert(this->cend(), x.begin(), x.end());
|
||||
this->insert(this->cend(), boost::make_move_iterator(x.begin()), boost::make_move_iterator(x.end()));
|
||||
STABLE_VECTOR_CHECK_INVARIANT;
|
||||
cod.release();
|
||||
}
|
||||
@@ -808,7 +809,7 @@ class stable_vector
|
||||
//Move allocator if needed
|
||||
container_detail::move_alloc(this_alloc, x_alloc, flag);
|
||||
//Take resources
|
||||
this->index = boost::move(x.index);
|
||||
this->index.swap(x.index);
|
||||
this->priv_swap_members(x);
|
||||
}
|
||||
//Else do a one by one move
|
||||
|
Reference in New Issue
Block a user