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 //////////////////////////////////////////////////////////////////////////////
12 #include <boost/move/utility_core.hpp>
14 #include <boost/utility/enable_if.hpp>
15 #include "../example/movable.hpp"
16 #include "../example/copymovable.hpp"
26 template<class MaybeRvalue
>
27 void catch_test(BOOST_RV_REF(MaybeRvalue
)
28 #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
29 ,typename ::boost::enable_if
< ::boost::has_move_emulation_enabled
<MaybeRvalue
> >::type
* = 0
30 #endif //BOOST_NO_CXX11_RVALUE_REFERENCES
34 template<class MaybeRvalue
>
35 void catch_test(BOOST_COPY_ASSIGN_REF(MaybeRvalue
)
36 #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
37 ,typename ::boost::enable_if
< ::boost::has_move_emulation_enabled
<MaybeRvalue
> >::type
* = 0
38 #endif //BOOST_NO_CXX11_RVALUE_REFERENCES
43 template<class MaybeRvalue
>
44 void catch_test(MaybeRvalue
&
45 #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
46 ,typename ::boost::enable_if
< ::boost::has_move_emulation_enabled
<MaybeRvalue
> >::type
* = 0
47 #endif //BOOST_NO_CXX11_RVALUE_REFERENCES
51 #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
52 template<class MaybeRvalue
>
53 void catch_test(const MaybeRvalue
&
54 ,typename ::boost::disable_if
< ::boost::has_move_emulation_enabled
<MaybeRvalue
> >::type
* = 0
57 #endif //BOOST_NO_CXX11_RVALUE_REFERENCES
59 movable
create_movable()
62 copy_movable
create_copy_movable()
63 { return copy_movable(); }
65 non_movable
create_non_movable()
66 { return non_movable(); }
73 catch_test
<movable
>(boost::move(m
));
74 #ifdef BOOST_CATCH_CONST_RLVALUE
75 catch_test
<movable
>(create_movable());
77 catch_test
<movable
>(m
);
78 catch_test
<movable
>(constm
);
80 const copy_movable constcm
;
81 catch_test
<copy_movable
>(boost::move(cm
));
82 catch_test
<copy_movable
>(create_copy_movable());
83 catch_test
<copy_movable
>(cm
);
84 catch_test
<copy_movable
>(constcm
);
86 const non_movable constnm
;
87 catch_test
<non_movable
>(boost::move(nm
));
88 catch_test
<non_movable
>(create_non_movable());
89 catch_test
<non_movable
>(nm
);
90 catch_test
<non_movable
>(constnm
);
93 template<class MaybeMovableOnly
, class MaybeRvalue
>
94 void function_construct(BOOST_FWD_REF(MaybeRvalue
) x
)
96 //Moves in case Convertible is boost::rv<movable> copies otherwise
97 //For C++0x perfect forwarding
98 MaybeMovableOnly
m(boost::forward
<MaybeRvalue
>(x
));
104 function_construct
<movable
>(boost::move(m
));
106 // function_construct<non_movable>(boost::move(nm));
107 // const non_movable cnm;
108 // function_construct<non_movable>(cnm);