mirror of
https://github.com/boostorg/intrusive.git
synced 2025-08-03 22:44:43 +02:00
Added experimental move semantics to containers. Undocumented
[SVN r70300]
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// (C) Copyright Ion Gaztanaga 2007-2009
|
// (C) Copyright Ion Gaztanaga 2007-2011
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
@@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include <boost/detail/lightweight_test.hpp>
|
||||||
#include <boost/intrusive/detail/mpl.hpp>
|
#include <boost/intrusive/detail/mpl.hpp>
|
||||||
|
#include <boost/move/move.hpp>
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
namespace intrusive {
|
namespace intrusive {
|
||||||
@@ -78,7 +79,7 @@ template< class Container, class Data >
|
|||||||
void test_sequence_container(Container & c, Data & d)
|
void test_sequence_container(Container & c, Data & d)
|
||||||
{
|
{
|
||||||
assert( d.size() > 2 );
|
assert( d.size() > 2 );
|
||||||
|
{
|
||||||
c.clear();
|
c.clear();
|
||||||
|
|
||||||
BOOST_TEST( c.size() == 0 );
|
BOOST_TEST( c.size() == 0 );
|
||||||
@@ -127,6 +128,18 @@ void test_sequence_container(Container & c, Data & d)
|
|||||||
|
|
||||||
BOOST_TEST( c.size() == 0 );
|
BOOST_TEST( c.size() == 0 );
|
||||||
BOOST_TEST( c.empty() );
|
BOOST_TEST( c.empty() );
|
||||||
|
}
|
||||||
|
{
|
||||||
|
c.clear();
|
||||||
|
c.insert( c.begin(), d.begin(), d.end() );
|
||||||
|
Container move_c(::boost::move(c));
|
||||||
|
BOOST_TEST( move_c.size() == d.size() );
|
||||||
|
BOOST_TEST( c.empty());
|
||||||
|
|
||||||
|
c = ::boost::move(move_c);
|
||||||
|
BOOST_TEST( c.size() == d.size() );
|
||||||
|
BOOST_TEST( move_c.empty());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template< class Container, class Data >
|
template< class Container, class Data >
|
||||||
@@ -212,9 +225,8 @@ void test_common_unordered_and_associative_container(Container & c, Data & d, bo
|
|||||||
template< class Container, class Data >
|
template< class Container, class Data >
|
||||||
void test_common_unordered_and_associative_container(Container & c, Data & d)
|
void test_common_unordered_and_associative_container(Container & c, Data & d)
|
||||||
{
|
{
|
||||||
{
|
|
||||||
typedef typename Container::size_type size_type;
|
typedef typename Container::size_type size_type;
|
||||||
|
{
|
||||||
assert( d.size() > 2 );
|
assert( d.size() > 2 );
|
||||||
|
|
||||||
c.clear();
|
c.clear();
|
||||||
@@ -233,7 +245,7 @@ void test_common_unordered_and_associative_container(Container & c, Data & d)
|
|||||||
|
|
||||||
c.erase(*da);
|
c.erase(*da);
|
||||||
BOOST_TEST( c.size() == old_size-1 );
|
BOOST_TEST( c.size() == old_size-1 );
|
||||||
//This should not eras anyone
|
//This should erase nothing
|
||||||
size_type second_erase = c.erase_and_dispose( *da, detail::null_disposer() );
|
size_type second_erase = c.erase_and_dispose( *da, detail::null_disposer() );
|
||||||
BOOST_TEST( second_erase == 0 );
|
BOOST_TEST( second_erase == 0 );
|
||||||
|
|
||||||
@@ -244,10 +256,24 @@ void test_common_unordered_and_associative_container(Container & c, Data & d)
|
|||||||
BOOST_TEST( c.find(*db) != c.end() );
|
BOOST_TEST( c.find(*db) != c.end() );
|
||||||
|
|
||||||
BOOST_TEST( c.equal_range(*db).first != c.end() );
|
BOOST_TEST( c.equal_range(*db).first != c.end() );
|
||||||
|
BOOST_TEST( c.equal_range(*da).first == c.equal_range(*da).second );
|
||||||
|
}
|
||||||
|
{
|
||||||
c.clear();
|
c.clear();
|
||||||
|
c.insert( d.begin(), d.end() );
|
||||||
|
size_type orig_size = c.size();
|
||||||
|
Container move_c(::boost::move(c));
|
||||||
|
BOOST_TEST(orig_size == move_c.size());
|
||||||
|
BOOST_TEST( c.empty());
|
||||||
|
for( typename Data::const_iterator di = d.begin(), de = d.end();
|
||||||
|
di != de; ++di )
|
||||||
|
{ BOOST_TEST( move_c.find(*di) != move_c.end() ); }
|
||||||
|
|
||||||
BOOST_TEST( c.equal_range(*da).first == c.end() );
|
c = ::boost::move(move_c);
|
||||||
|
for( typename Data::const_iterator di = d.begin(), de = d.end();
|
||||||
|
di != de; ++di )
|
||||||
|
{ BOOST_TEST( c.find(*di) != c.end() ); }
|
||||||
|
BOOST_TEST( move_c.empty());
|
||||||
}
|
}
|
||||||
typedef detail::bool_<is_unordered<Container>::value> enabler;
|
typedef detail::bool_<is_unordered<Container>::value> enabler;
|
||||||
test_common_unordered_and_associative_container(c, d, enabler());
|
test_common_unordered_and_associative_container(c, d, enabler());
|
||||||
|
Reference in New Issue
Block a user