• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include <boost/move/detail/config_begin.hpp>
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 
main()17 int 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(v.begin()), boost::make_move_iterator(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(boost::make_move_iterator(v2.begin()), boost::make_move_iterator(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 
44 #include <boost/move/detail/config_end.hpp>
45