1// Boost.Geometry.Index varray
2// Unit Test
3
4// Copyright (c) 2009 Ion Gaztanaga
5// Copyright (c) 2012-2013 Adam Wulkiewicz, Lodz, Poland.
6
7// Use, modification and distribution is subject to the Boost Software License,
8// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
9// http://www.boost.org/LICENSE_1_0.txt)
10
11#ifndef BOOST_GEOMETRY_INDEX_TEST_MOVABLE_HPP
12#define BOOST_GEOMETRY_INDEX_TEST_MOVABLE_HPP
13
14//[movable_definition
15//header file "movable.hpp"
16#include <boost/move/move.hpp>
17
18//A movable class
19class movable
20{
21 BOOST_MOVABLE_BUT_NOT_COPYABLE(movable)
22 int value_;
23
24public:
25 movable() : value_(1){}
26
27 //Move constructor and assignment
28 movable(BOOST_RV_REF(movable) m)
29 { value_ = m.value_; m.value_ = 0; }
30
31 movable & operator=(BOOST_RV_REF(movable) m)
32 { value_ = m.value_; m.value_ = 0; return *this; }
33
34 bool moved() const //Observer
35 { return value_ == 0; }
36};
37
38
39class copy_movable
40{
41 BOOST_COPYABLE_AND_MOVABLE(copy_movable)
42 size_t value_;
43
44public:
45 copy_movable(size_t value = 1) : value_(value){}
46
47 //Move constructor and assignment
48 copy_movable(BOOST_RV_REF(copy_movable) m)
49 { value_ = m.value_; m.value_ = 0; }
50
51 copy_movable(const copy_movable &m)
52 { value_ = m.value_; }
53
54 copy_movable & operator=(BOOST_RV_REF(copy_movable) m)
55 { value_ = m.value_; m.value_ = 0; return *this; }
56
57 copy_movable & operator=(BOOST_COPY_ASSIGN_REF(copy_movable) m)
58 { value_ = m.value_; return *this; }
59
60 bool moved() const //Observer
61 { return value_ == 0; }
62
63 bool operator==(const copy_movable& m) const
64 { return value_ == m.value_; }
65};
66
67struct copy_movable_wrapper
68{
69 copy_movable cm;
70};
71
72copy_movable produce()
73{ return copy_movable(); }
74
75namespace boost{
76
77template<>
78struct has_nothrow_move<movable>
79{
80 static const bool value = true;
81};
82
83template<>
84struct has_nothrow_move<copy_movable>
85{
86 static const bool value = true;
87};
88
89} //namespace boost{
90//]
91
92#endif //BOOST_GEOMETRY_INDEX_TEST_MOVABLE_HPP
93

source code of boost/libs/geometry/index/test/movable.hpp