1 | ////////////////////////////////////////////////////////////////////////////// |
---|---|
2 | // |
3 | // (C) Copyright 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 | #ifndef BOOST_MOVE_TEST_COPYMOVABLE_HPP |
12 | #define BOOST_MOVE_TEST_COPYMOVABLE_HPP |
13 | |
14 | //[copy_movable_definition |
15 | //header file "copymovable.hpp" |
16 | #include <boost/move/core.hpp> |
17 | |
18 | //A copy_movable class |
19 | class copy_movable |
20 | { |
21 | BOOST_COPYABLE_AND_MOVABLE(copy_movable) |
22 | int value_; |
23 | |
24 | public: |
25 | copy_movable() : value_(1){} |
26 | |
27 | //Move constructor and assignment |
28 | copy_movable(BOOST_RV_REF(copy_movable) m) |
29 | { value_ = m.value_; m.value_ = 0; } |
30 | |
31 | copy_movable(const copy_movable &m) |
32 | { value_ = m.value_; } |
33 | |
34 | copy_movable & operator=(BOOST_RV_REF(copy_movable) m) |
35 | { value_ = m.value_; m.value_ = 0; return *this; } |
36 | |
37 | copy_movable & operator=(BOOST_COPY_ASSIGN_REF(copy_movable) m) |
38 | { value_ = m.value_; return *this; } |
39 | |
40 | bool moved() const //Observer |
41 | { return value_ == 0; } |
42 | }; |
43 | |
44 | //A copyable-only class |
45 | class copyable |
46 | {}; |
47 | |
48 | //A copyable-only class |
49 | class non_copy_movable |
50 | { |
51 | public: |
52 | non_copy_movable(){} |
53 | private: |
54 | non_copy_movable(const non_copy_movable&); |
55 | non_copy_movable& operator=(const non_copy_movable&); |
56 | }; |
57 | |
58 | //] |
59 | |
60 | #endif //BOOST_MOVE_TEST_COPYMOVABLE_HPP |
61 |