blob: 7b1d990e8daaede4e11891d6ae08df36b0c73172 [file] [log] [blame]
Brian Silverman1f5d3982018-08-04 23:37:52 -07001//////////////////////////////////////////////////////////////////////////////
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#include <boost/move/detail/config_begin.hpp>
15
16//[movable_definition
17//header file "movable.hpp"
18#include <boost/move/core.hpp>
19#include <boost/move/traits.hpp>
20
21//A movable class
22class movable
23{
24 BOOST_MOVABLE_BUT_NOT_COPYABLE(movable)
25 int value_;
26
27 public:
28 movable() : value_(1){}
29
30 //Move constructor and assignment
31 movable(BOOST_RV_REF(movable) m)
32 { value_ = m.value_; m.value_ = 0; }
33
34 movable & operator=(BOOST_RV_REF(movable) m)
35 { value_ = m.value_; m.value_ = 0; return *this; }
36
37 bool moved() const //Observer
38 { return !value_; }
39
40 int value() const //Observer
41 { return value_; }
42};
43
44namespace boost{
45
46template<>
47struct has_nothrow_move<movable>
48{
49 static const bool value = true;
50};
51
52} //namespace boost{
53//]
54
55#include <boost/move/detail/config_end.hpp>
56
57#endif //BOOST_MOVE_TEST_MOVABLE_HPP