////////////////////////////////////////////////////////////////////////////// // // (C) Copyright David Abrahams, Vicente Botet, Ion Gaztanaga 2009-2012. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // See http://www.boost.org/libs/move for documentation. // ////////////////////////////////////////////////////////////////////////////// #include #include #include #include "../example/movable.hpp" #include "../example/copymovable.hpp" #include class non_movable { public: non_movable() {} }; template void catch_test(BOOST_RV_REF(MaybeRvalue) x #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES ,typename ::boost::enable_if< ::boost::has_move_emulation_enabled >::type* = 0 #endif //BOOST_NO_CXX11_RVALUE_REFERENCES ) { (void)x;} template void catch_test(BOOST_COPY_ASSIGN_REF(MaybeRvalue) x #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES ,typename ::boost::enable_if< ::boost::has_move_emulation_enabled >::type* = 0 #endif //BOOST_NO_CXX11_RVALUE_REFERENCES ) { (void)x;} template void catch_test(MaybeRvalue &x #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES ,typename ::boost::enable_if< ::boost::has_move_emulation_enabled >::type* = 0 #endif //BOOST_NO_CXX11_RVALUE_REFERENCES ) { (void)x;} #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES template void catch_test(const MaybeRvalue& x ,typename ::boost::disable_if< ::boost::has_move_emulation_enabled >::type* = 0 ) { (void)x;} #endif //BOOST_NO_CXX11_RVALUE_REFERENCES movable create_movable() { return movable(); } copy_movable create_copy_movable() { return copy_movable(); } non_movable create_non_movable() { return non_movable(); } void catch_test() { movable m; const movable constm; catch_test(boost::move(m)); #ifdef BOOST_CATCH_CONST_RLVALUE catch_test(create_movable()); #endif catch_test(m); catch_test(constm); copy_movable cm; const copy_movable constcm; catch_test(boost::move(cm)); catch_test(create_copy_movable()); catch_test(cm); catch_test(constcm); non_movable nm; const non_movable constnm; catch_test(boost::move(nm)); catch_test(create_non_movable()); catch_test(nm); catch_test(constnm); } template void function_construct(BOOST_FWD_REF(MaybeRvalue) x) { //Moves in case Convertible is boost::rv copies otherwise //For C++0x perfect forwarding MaybeMovableOnly m(boost::forward(x)); } void forward_test() { movable m; function_construct(boost::move(m)); // non_movable nm; // function_construct(boost::move(nm)); // const non_movable cnm; // function_construct(cnm); } int main() { catch_test(); forward_test(); return 0; } #include