diff -dur trunc/boost/any.hpp fix/boost/any.hpp
old
|
new
|
|
19 | 19 | #include <boost/throw_exception.hpp> |
20 | 20 | #include <boost/static_assert.hpp> |
21 | 21 | |
| 22 | #include <boost/move/move.hpp> |
| 23 | |
22 | 24 | // See boost/python/type_id.hpp |
23 | 25 | // TODO: add BOOST_TYPEID_COMPARE_BY_NAME to config.hpp |
24 | 26 | # if (defined(__GNUC__) && __GNUC__ >= 3) \ |
… |
… |
|
34 | 36 | { |
35 | 37 | class any |
36 | 38 | { |
| 39 | BOOST_COPYABLE_AND_MOVABLE_ALT(any) |
37 | 40 | public: // structors |
38 | 41 | |
39 | 42 | any() |
… |
… |
|
47 | 50 | { |
48 | 51 | } |
49 | 52 | |
| 53 | template<typename ValueType> |
| 54 | any(BOOST_RV_REF(ValueType) value,typename BOOST_MOVE_MPL_NS::disable_if<BOOST_MOVE_MPL_NS::is_lvalue_reference<ValueType> >::type* = 0) |
| 55 | : content(new holder<typename remove_reference<ValueType>::type >(boost::move(value))) |
| 56 | { |
| 57 | } |
| 58 | |
50 | 59 | any(const any & other) |
51 | 60 | : content(other.content ? other.content->clone() : 0) |
52 | 61 | { |
53 | 62 | } |
54 | 63 | |
| 64 | any(BOOST_RV_REF(any) other) |
| 65 | : content(other.content) |
| 66 | { |
| 67 | other.content = 0; |
| 68 | } |
| 69 | |
55 | 70 | ~any() |
56 | 71 | { |
57 | 72 | delete content; |
… |
… |
|
72 | 87 | return *this; |
73 | 88 | } |
74 | 89 | |
| 90 | template<typename ValueType> |
| 91 | typename BOOST_MOVE_MPL_NS::disable_if<BOOST_MOVE_MPL_NS::is_lvalue_reference<ValueType>,any >::type& operator=(BOOST_RV_REF(ValueType) rhs) |
| 92 | { |
| 93 | any(boost::move(rhs)).swap(*this); |
| 94 | return *this; |
| 95 | } |
| 96 | |
75 | 97 | any & operator=(any rhs) |
76 | 98 | { |
77 | 99 | rhs.swap(*this); |
78 | 100 | return *this; |
79 | 101 | } |
80 | 102 | |
| 103 | any & operator=(BOOST_RV_REF(any) rhs) |
| 104 | { |
| 105 | rhs.swap(*this); |
| 106 | return *this; |
| 107 | } |
| 108 | |
81 | 109 | public: // queries |
82 | 110 | |
83 | 111 | bool empty() const |
… |
… |
|
119 | 147 | |
120 | 148 | holder(const ValueType & value) |
121 | 149 | : held(value) |
| 150 | { |
| 151 | } |
| 152 | |
| 153 | holder(BOOST_RV_REF(ValueType) value) |
| 154 | : held(boost::move(value)) |
122 | 155 | { |
123 | 156 | } |
124 | 157 | |