Chris@16
|
1 //////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
2 //
|
Chris@16
|
3 // (C) Copyright Ion Gaztanaga 2010-2012.
|
Chris@16
|
4 // Distributed under the Boost Software License, Version 1.0.
|
Chris@16
|
5 // (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
6 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
7 //
|
Chris@16
|
8 // See http://www.boost.org/libs/move for documentation.
|
Chris@16
|
9 //
|
Chris@16
|
10 //////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
11
|
Chris@16
|
12 #ifndef BOOST_MOVE_MOVE_HELPERS_HPP
|
Chris@16
|
13 #define BOOST_MOVE_MOVE_HELPERS_HPP
|
Chris@16
|
14
|
Chris@101
|
15 #ifndef BOOST_CONFIG_HPP
|
Chris@101
|
16 # include <boost/config.hpp>
|
Chris@16
|
17 #endif
|
Chris@101
|
18 #
|
Chris@101
|
19 #if defined(BOOST_HAS_PRAGMA_ONCE)
|
Chris@101
|
20 # pragma once
|
Chris@16
|
21 #endif
|
Chris@16
|
22
|
Chris@101
|
23 #include <boost/move/utility_core.hpp>
|
Chris@101
|
24 #include <boost/move/detail/meta_utils.hpp>
|
Chris@16
|
25
|
Chris@16
|
26 #if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
Chris@101
|
27
|
Chris@16
|
28 #define BOOST_MOVE_CATCH_CONST(U) \
|
Chris@101
|
29 typename ::boost::move_detail::if_< ::boost::move_detail::is_class_or_union<U>, BOOST_CATCH_CONST_RLVALUE(U), const U &>::type
|
Chris@16
|
30 #define BOOST_MOVE_CATCH_RVALUE(U)\
|
Chris@101
|
31 typename ::boost::move_detail::if_< ::boost::move_detail::is_class_or_union<U>, BOOST_RV_REF(U), ::boost::move_detail::nat>::type
|
Chris@16
|
32 #define BOOST_MOVE_CATCH_FWD(U) BOOST_FWD_REF(U)
|
Chris@16
|
33 #else
|
Chris@16
|
34 #define BOOST_MOVE_CATCH_CONST(U) const U &
|
Chris@16
|
35 #define BOOST_MOVE_CATCH_RVALUE(U) U &&
|
Chris@16
|
36 #define BOOST_MOVE_CATCH_FWD(U) U &&
|
Chris@16
|
37 #endif
|
Chris@16
|
38
|
Chris@16
|
39 #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
|
Chris@16
|
40 #define BOOST_MOVE_CONVERSION_AWARE_CATCH(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION)\
|
Chris@16
|
41 RETURN_VALUE PUB_FUNCTION(BOOST_MOVE_CATCH_CONST(TYPE) x)\
|
Chris@16
|
42 { return FWD_FUNCTION(static_cast<const TYPE&>(x)); }\
|
Chris@16
|
43 \
|
Chris@16
|
44 RETURN_VALUE PUB_FUNCTION(BOOST_MOVE_CATCH_RVALUE(TYPE) x) \
|
Chris@16
|
45 { return FWD_FUNCTION(::boost::move(x)); }\
|
Chris@16
|
46 \
|
Chris@16
|
47 RETURN_VALUE PUB_FUNCTION(TYPE &x)\
|
Chris@16
|
48 { return FWD_FUNCTION(const_cast<const TYPE &>(x)); }\
|
Chris@16
|
49 \
|
Chris@16
|
50 template<class BOOST_MOVE_TEMPL_PARAM>\
|
Chris@101
|
51 typename ::boost::move_detail::enable_if_c\
|
Chris@101
|
52 < ::boost::move_detail::is_class_or_union<TYPE>::value &&\
|
Chris@101
|
53 ::boost::move_detail::is_same<TYPE, BOOST_MOVE_TEMPL_PARAM>::value &&\
|
Chris@16
|
54 !::boost::has_move_emulation_enabled<BOOST_MOVE_TEMPL_PARAM>::value\
|
Chris@16
|
55 , RETURN_VALUE >::type\
|
Chris@16
|
56 PUB_FUNCTION(const BOOST_MOVE_TEMPL_PARAM &u)\
|
Chris@16
|
57 { return FWD_FUNCTION(u); }\
|
Chris@16
|
58 \
|
Chris@16
|
59 template<class BOOST_MOVE_TEMPL_PARAM>\
|
Chris@101
|
60 typename ::boost::move_detail::enable_if_c\
|
Chris@101
|
61 < (!::boost::move_detail::is_class_or_union<BOOST_MOVE_TEMPL_PARAM>::value || \
|
Chris@16
|
62 !::boost::move_detail::is_rv<BOOST_MOVE_TEMPL_PARAM>::value) && \
|
Chris@101
|
63 !::boost::move_detail::is_same<TYPE, BOOST_MOVE_TEMPL_PARAM>::value \
|
Chris@16
|
64 , RETURN_VALUE >::type\
|
Chris@16
|
65 PUB_FUNCTION(const BOOST_MOVE_TEMPL_PARAM &u)\
|
Chris@16
|
66 {\
|
Chris@16
|
67 TYPE t(u);\
|
Chris@16
|
68 return FWD_FUNCTION(::boost::move(t));\
|
Chris@16
|
69 }\
|
Chris@16
|
70 //
|
Chris@101
|
71
|
Chris@16
|
72 #elif (defined(_MSC_VER) && (_MSC_VER == 1600))
|
Chris@16
|
73
|
Chris@16
|
74 #define BOOST_MOVE_CONVERSION_AWARE_CATCH(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION)\
|
Chris@16
|
75 RETURN_VALUE PUB_FUNCTION(BOOST_MOVE_CATCH_CONST(TYPE) x)\
|
Chris@16
|
76 { return FWD_FUNCTION(static_cast<const TYPE&>(x)); }\
|
Chris@16
|
77 \
|
Chris@16
|
78 RETURN_VALUE PUB_FUNCTION(BOOST_MOVE_CATCH_RVALUE(TYPE) x) \
|
Chris@16
|
79 { return FWD_FUNCTION(::boost::move(x)); }\
|
Chris@16
|
80 \
|
Chris@16
|
81 template<class BOOST_MOVE_TEMPL_PARAM>\
|
Chris@101
|
82 typename ::boost::move_detail::enable_if_c\
|
Chris@101
|
83 < !::boost::move_detail::is_same<TYPE, BOOST_MOVE_TEMPL_PARAM>::value\
|
Chris@16
|
84 , RETURN_VALUE >::type\
|
Chris@16
|
85 PUB_FUNCTION(const BOOST_MOVE_TEMPL_PARAM &u)\
|
Chris@16
|
86 {\
|
Chris@16
|
87 TYPE t(u);\
|
Chris@16
|
88 return FWD_FUNCTION(::boost::move(t));\
|
Chris@16
|
89 }\
|
Chris@16
|
90 //
|
Chris@16
|
91
|
Chris@16
|
92 #else
|
Chris@16
|
93
|
Chris@16
|
94 #define BOOST_MOVE_CONVERSION_AWARE_CATCH(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION)\
|
Chris@16
|
95 RETURN_VALUE PUB_FUNCTION(BOOST_MOVE_CATCH_CONST(TYPE) x)\
|
Chris@16
|
96 { return FWD_FUNCTION(static_cast<const TYPE&>(x)); }\
|
Chris@16
|
97 \
|
Chris@16
|
98 RETURN_VALUE PUB_FUNCTION(BOOST_MOVE_CATCH_RVALUE(TYPE) x) \
|
Chris@16
|
99 { return FWD_FUNCTION(::boost::move(x)); }\
|
Chris@16
|
100 //
|
Chris@16
|
101
|
Chris@16
|
102 #endif
|
Chris@16
|
103
|
Chris@16
|
104
|
Chris@16
|
105 #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
|
Chris@16
|
106
|
Chris@16
|
107 #define BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION, ARG1, UNLESS_CONVERTIBLE_TO)\
|
Chris@16
|
108 RETURN_VALUE PUB_FUNCTION(ARG1 arg1, BOOST_MOVE_CATCH_CONST(TYPE) x)\
|
Chris@16
|
109 { return FWD_FUNCTION(arg1, static_cast<const TYPE&>(x)); }\
|
Chris@16
|
110 \
|
Chris@16
|
111 RETURN_VALUE PUB_FUNCTION(ARG1 arg1, BOOST_MOVE_CATCH_RVALUE(TYPE) x) \
|
Chris@16
|
112 { return FWD_FUNCTION(arg1, ::boost::move(x)); }\
|
Chris@16
|
113 \
|
Chris@16
|
114 RETURN_VALUE PUB_FUNCTION(ARG1 arg1, TYPE &x)\
|
Chris@16
|
115 { return FWD_FUNCTION(arg1, const_cast<const TYPE &>(x)); }\
|
Chris@16
|
116 \
|
Chris@16
|
117 template<class BOOST_MOVE_TEMPL_PARAM>\
|
Chris@101
|
118 typename ::boost::move_detail::enable_if_c<\
|
Chris@101
|
119 ::boost::move_detail::is_same<TYPE, BOOST_MOVE_TEMPL_PARAM>::value &&\
|
Chris@16
|
120 !::boost::has_move_emulation_enabled<BOOST_MOVE_TEMPL_PARAM>::value\
|
Chris@16
|
121 , RETURN_VALUE >::type\
|
Chris@16
|
122 PUB_FUNCTION(ARG1 arg1, const BOOST_MOVE_TEMPL_PARAM &u)\
|
Chris@16
|
123 { return FWD_FUNCTION(arg1, u); }\
|
Chris@16
|
124 \
|
Chris@16
|
125 template<class BOOST_MOVE_TEMPL_PARAM>\
|
Chris@101
|
126 typename ::boost::move_detail::enable_if_c<\
|
Chris@16
|
127 !::boost::move_detail::is_rv<BOOST_MOVE_TEMPL_PARAM>::value && \
|
Chris@101
|
128 !::boost::move_detail::is_same<TYPE, BOOST_MOVE_TEMPL_PARAM>::value && \
|
Chris@101
|
129 !::boost::move_detail::is_convertible<BOOST_MOVE_TEMPL_PARAM, UNLESS_CONVERTIBLE_TO>::value \
|
Chris@16
|
130 , RETURN_VALUE >::type\
|
Chris@16
|
131 PUB_FUNCTION(ARG1 arg1, const BOOST_MOVE_TEMPL_PARAM &u)\
|
Chris@16
|
132 {\
|
Chris@16
|
133 TYPE t(u);\
|
Chris@16
|
134 return FWD_FUNCTION(arg1, ::boost::move(t));\
|
Chris@16
|
135 }\
|
Chris@16
|
136 //
|
Chris@16
|
137
|
Chris@16
|
138 #elif (defined(_MSC_VER) && (_MSC_VER == 1600))
|
Chris@16
|
139
|
Chris@16
|
140 #define BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION, ARG1, UNLESS_CONVERTIBLE_TO)\
|
Chris@16
|
141 RETURN_VALUE PUB_FUNCTION(ARG1 arg1, BOOST_MOVE_CATCH_CONST(TYPE) x)\
|
Chris@16
|
142 { return FWD_FUNCTION(arg1, static_cast<const TYPE&>(x)); }\
|
Chris@16
|
143 \
|
Chris@16
|
144 RETURN_VALUE PUB_FUNCTION(ARG1 arg1, BOOST_MOVE_CATCH_RVALUE(TYPE) x) \
|
Chris@16
|
145 { return FWD_FUNCTION(arg1, ::boost::move(x)); }\
|
Chris@16
|
146 \
|
Chris@16
|
147 template<class BOOST_MOVE_TEMPL_PARAM>\
|
Chris@101
|
148 typename ::boost::move_detail::enable_if_c\
|
Chris@101
|
149 < !::boost::move_detail::is_same<TYPE, BOOST_MOVE_TEMPL_PARAM>::value && \
|
Chris@101
|
150 !::boost::move_detail::is_convertible<BOOST_MOVE_TEMPL_PARAM, UNLESS_CONVERTIBLE_TO>::value \
|
Chris@16
|
151 , RETURN_VALUE >::type\
|
Chris@16
|
152 PUB_FUNCTION(ARG1 arg1, const BOOST_MOVE_TEMPL_PARAM &u)\
|
Chris@16
|
153 {\
|
Chris@16
|
154 TYPE t(u);\
|
Chris@16
|
155 return FWD_FUNCTION(arg1, ::boost::move(t));\
|
Chris@16
|
156 }\
|
Chris@16
|
157 //
|
Chris@16
|
158
|
Chris@16
|
159 #else
|
Chris@16
|
160
|
Chris@16
|
161 #define BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION, ARG1, UNLESS_CONVERTIBLE_TO)\
|
Chris@16
|
162 RETURN_VALUE PUB_FUNCTION(ARG1 arg1, BOOST_MOVE_CATCH_CONST(TYPE) x)\
|
Chris@16
|
163 { return FWD_FUNCTION(arg1, static_cast<const TYPE&>(x)); }\
|
Chris@16
|
164 \
|
Chris@16
|
165 RETURN_VALUE PUB_FUNCTION(ARG1 arg1, BOOST_MOVE_CATCH_RVALUE(TYPE) x) \
|
Chris@16
|
166 { return FWD_FUNCTION(arg1, ::boost::move(x)); }\
|
Chris@16
|
167 //
|
Chris@16
|
168
|
Chris@16
|
169 #endif
|
Chris@16
|
170
|
Chris@16
|
171 #endif //#ifndef BOOST_MOVE_MOVE_HELPERS_HPP
|