]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/move/example/movable.hpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / libs / move / example / movable.hpp
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_MOVABLE_HPP
12 #define BOOST_MOVE_TEST_MOVABLE_HPP
13
14 //[movable_definition
15 //header file "movable.hpp"
16 #include <boost/move/core.hpp>
17 #include <boost/move/traits.hpp>
18
19 //A movable class
20 class movable
21 {
22 BOOST_MOVABLE_BUT_NOT_COPYABLE(movable)
23 int value_;
24
25 public:
26 movable() : value_(1){}
27
28 //Move constructor and assignment
29 movable(BOOST_RV_REF(movable) m)
30 { value_ = m.value_; m.value_ = 0; }
31
32 movable & operator=(BOOST_RV_REF(movable) m)
33 { value_ = m.value_; m.value_ = 0; return *this; }
34
35 bool moved() const //Observer
36 { return !value_; }
37
38 int value() const //Observer
39 { return value_; }
40 };
41
42 namespace boost{
43
44 template<>
45 struct has_nothrow_move<movable>
46 {
47 static const bool value = true;
48 };
49
50 } //namespace boost{
51 //]
52
53 #endif //BOOST_MOVE_TEST_MOVABLE_HPP