1 //////////////////////////////////////////////////////////////////////////////
3 // (C) Copyright David Abrahams, Vicente Botet, Ion Gaztanaga 2009-2012.
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)
8 // See http://www.boost.org/libs/move for documentation.
10 //////////////////////////////////////////////////////////////////////////////
11 #include <boost/move/detail/config_begin.hpp>
12 #include <boost/move/utility_core.hpp>
13 #include <boost/utility/enable_if.hpp>
14 #include "../example/movable.hpp"
15 #include "../example/copymovable.hpp"
25 template<class MaybeRvalue
>
26 void catch_test(BOOST_RV_REF(MaybeRvalue
) x
27 #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
28 ,typename ::boost::enable_if
< ::boost::has_move_emulation_enabled
<MaybeRvalue
> >::type
* = 0
29 #endif //BOOST_NO_CXX11_RVALUE_REFERENCES
33 template<class MaybeRvalue
>
34 void catch_test(BOOST_COPY_ASSIGN_REF(MaybeRvalue
) x
35 #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
36 ,typename ::boost::enable_if
< ::boost::has_move_emulation_enabled
<MaybeRvalue
> >::type
* = 0
37 #endif //BOOST_NO_CXX11_RVALUE_REFERENCES
42 template<class MaybeRvalue
>
43 void catch_test(MaybeRvalue
&x
44 #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
45 ,typename ::boost::enable_if
< ::boost::has_move_emulation_enabled
<MaybeRvalue
> >::type
* = 0
46 #endif //BOOST_NO_CXX11_RVALUE_REFERENCES
50 #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
51 template<class MaybeRvalue
>
52 void catch_test(const MaybeRvalue
& x
53 ,typename ::boost::disable_if
< ::boost::has_move_emulation_enabled
<MaybeRvalue
> >::type
* = 0
56 #endif //BOOST_NO_CXX11_RVALUE_REFERENCES
58 movable
create_movable()
61 copy_movable
create_copy_movable()
62 { return copy_movable(); }
64 non_movable
create_non_movable()
65 { return non_movable(); }
72 catch_test
<movable
>(boost::move(m
));
73 #ifdef BOOST_CATCH_CONST_RLVALUE
74 catch_test
<movable
>(create_movable());
76 catch_test
<movable
>(m
);
77 catch_test
<movable
>(constm
);
79 const copy_movable constcm
;
80 catch_test
<copy_movable
>(boost::move(cm
));
81 catch_test
<copy_movable
>(create_copy_movable());
82 catch_test
<copy_movable
>(cm
);
83 catch_test
<copy_movable
>(constcm
);
85 const non_movable constnm
;
86 catch_test
<non_movable
>(boost::move(nm
));
87 catch_test
<non_movable
>(create_non_movable());
88 catch_test
<non_movable
>(nm
);
89 catch_test
<non_movable
>(constnm
);
92 template<class MaybeMovableOnly
, class MaybeRvalue
>
93 void function_construct(BOOST_FWD_REF(MaybeRvalue
) x
)
95 //Moves in case Convertible is boost::rv<movable> copies otherwise
96 //For C++0x perfect forwarding
97 MaybeMovableOnly
m(boost::forward
<MaybeRvalue
>(x
));
103 function_construct
<movable
>(boost::move(m
));
105 // function_construct<non_movable>(boost::move(nm));
106 // const non_movable cnm;
107 // function_construct<non_movable>(cnm);
117 #include <boost/move/detail/config_end.hpp>