Added experimental move semantics to containers. Undocumented

[SVN r70299]
This commit is contained in:
Ion Gaztañaga
2011-03-21 08:58:28 +00:00
parent 75df697ca8
commit 514e48a9d3
15 changed files with 589 additions and 113 deletions

View File

@@ -38,6 +38,7 @@
#include <boost/intrusive/options.hpp>
#include <boost/intrusive/sgtree_algorithms.hpp>
#include <boost/intrusive/link_mode.hpp>
#include <boost/move/move.hpp>
namespace boost {
namespace intrusive {
@@ -254,8 +255,7 @@ class sgtree_impl
typedef typename alpha_traits::multiply_by_alpha_t multiply_by_alpha_t;
//noncopyable
sgtree_impl (const sgtree_impl&);
sgtree_impl operator =(const sgtree_impl&);
BOOST_MOVABLE_BUT_NOT_COPYABLE(sgtree_impl)
enum { safemode_or_autounlink =
(int)real_value_traits::link_mode == (int)auto_unlink ||
@@ -303,6 +303,12 @@ class sgtree_impl
value_compare &priv_comp()
{ return data_.node_plus_pred_.get(); }
const value_traits &priv_value_traits() const
{ return data_; }
value_traits &priv_value_traits()
{ return data_; }
const node &priv_header() const
{ return data_.node_plus_pred_.header_plus_alpha_.header_; }
@@ -395,6 +401,21 @@ class sgtree_impl
this->insert_equal(b, e);
}
//! <b>Effects</b>: to-do
//!
sgtree_impl(BOOST_RV_REF(sgtree_impl) x)
: data_(::boost::move(x.priv_comp()), ::boost::move(x.priv_value_traits()))
{
node_algorithms::init_header(&priv_header());
this->priv_size_traits().set_size(size_type(0));
this->swap(x);
}
//! <b>Effects</b>: to-do
//!
sgtree_impl& operator=(BOOST_RV_REF(sgtree_impl) x)
{ this->swap(x); return *this; }
//! <b>Effects</b>: Detaches all elements from this. The objects in the set
//! are not deleted (i.e. no destructors are called), but the nodes according to
//! the value_traits template parameter are reinitialized and thus can be reused.
@@ -1838,6 +1859,8 @@ class sgtree
#endif
>::type Base;
BOOST_MOVABLE_BUT_NOT_COPYABLE(sgtree)
public:
typedef typename Base::value_compare value_compare;
typedef typename Base::value_traits value_traits;
@@ -1860,6 +1883,13 @@ class sgtree
: Base(unique, b, e, cmp, v_traits)
{}
sgtree(BOOST_RV_REF(sgtree) x)
: Base(::boost::move(static_cast<Base&>(x)))
{}
sgtree& operator=(BOOST_RV_REF(sgtree) x)
{ this->Base::operator=(::boost::move(static_cast<Base&>(x))); return *this; }
static sgtree &container_from_end_iterator(iterator end_iterator)
{ return static_cast<sgtree &>(Base::container_from_end_iterator(end_iterator)); }