2011-03-17 16:41:04 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// (C) Copyright David Abrahams, Vicente Botet, Ion Gaztanaga 2009.
|
|
|
|
// Distributed under the Boost Software License, Version 1.0.
|
|
|
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
|
|
|
// http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
//
|
|
|
|
// See http://www.boost.org/libs/move for documentation.
|
|
|
|
//
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
2012-12-01 22:50:46 +00:00
|
|
|
#include <boost/move/detail/config_begin.hpp>
|
|
|
|
#include <boost/move/iterator.hpp>
|
2011-08-30 12:53:03 +00:00
|
|
|
#include <boost/container/vector.hpp>
|
2011-03-17 16:41:04 +00:00
|
|
|
#include "../example/movable.hpp"
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
2011-08-30 12:53:03 +00:00
|
|
|
namespace bc = ::boost::container;
|
2011-03-17 16:41:04 +00:00
|
|
|
//Default construct 10 movable objects
|
2011-08-30 12:53:03 +00:00
|
|
|
bc::vector<movable> v(10);
|
2011-03-17 16:41:04 +00:00
|
|
|
|
|
|
|
//Test default constructed value
|
|
|
|
if(v[0].moved()){
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Move values
|
2011-08-30 12:53:03 +00:00
|
|
|
bc::vector<movable> v2
|
2011-03-17 16:41:04 +00:00
|
|
|
(boost::make_move_iterator(v.begin()), boost::make_move_iterator(v.end()));
|
|
|
|
|
|
|
|
//Test values have been moved
|
|
|
|
if(!v[0].moved()){
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(v2.size() != 10){
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Move again
|
|
|
|
v.assign(boost::make_move_iterator(v2.begin()), boost::make_move_iterator(v2.end()));
|
|
|
|
|
|
|
|
//Test values have been moved
|
|
|
|
if(!v2[0].moved()){
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(v[0].moved()){
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-12-01 22:50:46 +00:00
|
|
|
#include <boost/move/detail/config_end.hpp>
|