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/algorithm.hpp> |
13 | #include <boost/container/vector.hpp> |
14 | #include "../example/movable.hpp" |
15 | |
16 | int main() |
17 | { |
18 | namespace bc = ::boost::container; |
19 | //Default construct 10 movable objects |
20 | bc::vector<movable> v(10); |
21 | bc::vector<movable> v2(10); |
22 | |
23 | //Move to v2 |
24 | boost::move(f: v.begin(), l: v.end(), result: v2.begin()); |
25 | |
26 | //Test values have been moved |
27 | if(!v[0].moved()){ |
28 | return 1; |
29 | } |
30 | |
31 | if(v2.size() != 10){ |
32 | return 1; |
33 | } |
34 | |
35 | if(v2[0].moved()){ |
36 | return 1; |
37 | } |
38 | |
39 | //Move to v again |
40 | boost::move_backward(f: v2.begin(), l: v2.end(), result: v.end()); |
41 | |
42 | //Test values have been moved |
43 | if(!v2[1].moved()){ |
44 | return 1; |
45 | } |
46 | |
47 | if(v.size() != 10){ |
48 | return 1; |
49 | } |
50 | |
51 | if(v[1].moved()){ |
52 | return 1; |
53 | } |
54 | |
55 | return 0; |
56 | } |
57 |