• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
19 class movable
20 {
21     BOOST_MOVABLE_BUT_NOT_COPYABLE(movable)
22     int value_;
23 
24 public:
movable()25     movable() : value_(1){}
26 
27     //Move constructor and assignment
movable(BOOST_RV_REF (movable)m)28     movable(BOOST_RV_REF(movable) m)
29     {  value_ = m.value_;   m.value_ = 0;  }
30 
operator =(BOOST_RV_REF (movable)m)31     movable & operator=(BOOST_RV_REF(movable) m)
32     {  value_ = m.value_;   m.value_ = 0;  return *this;  }
33 
moved() const34     bool moved() const //Observer
35     {  return value_ == 0; }
36 };
37 
38 
39 class copy_movable
40 {
41     BOOST_COPYABLE_AND_MOVABLE(copy_movable)
42     size_t value_;
43 
44 public:
copy_movable(size_t value=1)45     copy_movable(size_t value = 1) : value_(value){}
46 
47     //Move constructor and assignment
copy_movable(BOOST_RV_REF (copy_movable)m)48     copy_movable(BOOST_RV_REF(copy_movable) m)
49     {  value_ = m.value_;   m.value_ = 0;  }
50 
copy_movable(const copy_movable & m)51     copy_movable(const copy_movable &m)
52     {  value_ = m.value_;   }
53 
operator =(BOOST_RV_REF (copy_movable)m)54     copy_movable & operator=(BOOST_RV_REF(copy_movable) m)
55     {  value_ = m.value_;   m.value_ = 0;  return *this;  }
56 
operator =(BOOST_COPY_ASSIGN_REF (copy_movable)m)57     copy_movable & operator=(BOOST_COPY_ASSIGN_REF(copy_movable) m)
58     {  value_ = m.value_;   return *this;  }
59 
moved() const60     bool moved() const //Observer
61     {  return value_ == 0; }
62 
operator ==(const copy_movable & m) const63     bool operator==(const copy_movable& m) const
64     {  return value_ == m.value_; }
65 };
66 
67 struct copy_movable_wrapper
68 {
69    copy_movable cm;
70 };
71 
produce()72 copy_movable produce()
73 {  return copy_movable();  }
74 
75 namespace boost{
76 
77 template<>
78 struct has_nothrow_move<movable>
79 {
80    static const bool value = true;
81 };
82 
83 template<>
84 struct 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