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

@@ -31,7 +31,7 @@
#include <algorithm>
#include <cstddef> //std::size_t
#include <utility> //std::pair
//iG pending #include <boost/pointer_cast.hpp>
#include <boost/move/move.hpp>
namespace boost {
namespace intrusive {
@@ -148,13 +148,8 @@ class slist_impl
private:
typedef detail::size_holder<constant_time_size, size_type> size_traits;
//! This class is
//! non-copyable
slist_impl (const slist_impl&);
//! This class is
//! non-asignable
slist_impl &operator =(const slist_impl&);
//noncopyable
BOOST_MOVABLE_BUT_NOT_COPYABLE(slist_impl)
enum { safemode_or_autounlink =
(int)real_value_traits::link_mode == (int)auto_unlink ||
@@ -252,10 +247,10 @@ class slist_impl
real_value_traits &get_real_value_traits(detail::bool_<true>)
{ return data_.get_value_traits(*this); }
const value_traits &get_value_traits() const
const value_traits &priv_value_traits() const
{ return data_; }
value_traits &get_value_traits()
value_traits &priv_value_traits()
{ return data_; }
protected:
@@ -305,6 +300,21 @@ class slist_impl
this->insert_after(this->cbefore_begin(), b, e);
}
//! <b>Effects</b>: to-do
//!
slist_impl(BOOST_RV_REF(slist_impl) x)
: data_(::boost::move(x.priv_value_traits()))
{
this->priv_size_traits().set_size(size_type(0));
node_algorithms::init_header(this->get_root_node());
this->swap(x);
}
//! <b>Effects</b>: to-do
//!
slist_impl& operator=(BOOST_RV_REF(slist_impl) x)
{ this->swap(x); return *this; }
//! <b>Effects</b>: If it's a safe-mode
//! or auto-unlink value, the destructor does nothing
//! (ie. no code is generated). Otherwise it detaches all elements from this.
@@ -1313,8 +1323,8 @@ class slist_impl
if (node_traits::get_next(node_traits::get_next(this->get_root_node()))
!= this->get_root_node()) {
slist_impl carry(this->get_value_traits());
detail::array_initializer<slist_impl, 64> counter(this->get_value_traits());
slist_impl carry(this->priv_value_traits());
detail::array_initializer<slist_impl, 64> counter(this->priv_value_traits());
int fill = 0;
const_iterator last_inserted;
while(!this->empty()){
@@ -2084,6 +2094,8 @@ class slist
typedef typename Base::real_value_traits real_value_traits;
//Assert if passed value traits are compatible with the type
BOOST_STATIC_ASSERT((detail::is_same<typename real_value_traits::value_type, T>::value));
BOOST_MOVABLE_BUT_NOT_COPYABLE(slist)
public:
typedef typename Base::value_traits value_traits;
typedef typename Base::iterator iterator;
@@ -2098,6 +2110,13 @@ class slist
: Base(b, e, v_traits)
{}
slist(BOOST_RV_REF(slist) x)
: Base(::boost::move(static_cast<Base&>(x)))
{}
slist& operator=(BOOST_RV_REF(slist) x)
{ this->Base::operator=(::boost::move(static_cast<Base&>(x))); return *this; }
static slist &container_from_end_iterator(iterator end_iterator)
{ return static_cast<slist &>(Base::container_from_end_iterator(end_iterator)); }