forked from boostorg/container
Fix move constructors with unequal allocators and move/copy assignment of tree.
This commit is contained in:
1 parent
d0750f4493
commit
c2ea5da716
8 files changed
+25
-17
No files matched your search
@@ -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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user