1//////////////////////////////////////////////////////////////////////////////
2//
3// (C) Copyright David Abrahams, Vicente Botet, Ion Gaztanaga 2009.
4// Distributed under the Boost Software License, Version 1.0.
5// (See accompanying file LICENSE_1_0.txt or copy at
6// http://www.boost.org/LICENSE_1_0.txt)
7//
8// See http://www.boost.org/libs/move for documentation.
9//
10//////////////////////////////////////////////////////////////////////////////
11
12#include <boost/move/iterator.hpp>
13#include <boost/container/vector.hpp>
14#include <boost/core/lightweight_test.hpp>
15#include "../example/movable.hpp"
16
17int main()
18{
19 namespace bc = ::boost::container;
20 //Default construct 10 movable objects
21 bc::vector<movable> v(10);
22
23 //Test default constructed value
24 BOOST_TEST(!v[0].moved());
25
26 //Move values
27 bc::vector<movable> v2
28 (boost::make_move_iterator(it: v.begin()), boost::make_move_iterator(it: v.end()));
29
30 //Test values have been moved
31 BOOST_TEST(v[0].moved());
32 BOOST_TEST(v2.size() == 10);
33
34 //Move again
35 v.assign(first: boost::make_move_iterator(it: v2.begin()), last: boost::make_move_iterator(it: v2.end()));
36
37 //Test values have been moved
38 BOOST_TEST(v2[0].moved());
39 BOOST_TEST(!v[0].moved());
40
41 return ::boost::report_errors();
42}
43

source code of boost/libs/move/test/move_iterator.cpp