#include #include namespace movable_namespace { class movable { movable(movable&); movable& operator=(movable&); public: void swap(movable &) { /*some code */ } movable() {} ~movable() {} #ifdef BOOST_HAS_RVALUE_REFS movable(movable &&r) { this->swap(r); } #else movable(boost::detail::rv r) { this->swap(*r); } #endif //Declare the class as movable BOOST_ENABLE_MOVE_EMULATION(movable) BOOST_SWAP_BASED_MOVE_ASSIGN(movable) }; movable get_movable() { return movable(); } } //movable_namespace int main() { movable_namespace::movable m; movable_namespace::movable m2(boost::move(m)); m = boost::move(m2); m = movable_namespace::get_movable(); movable_namespace::movable m3(movable_namespace::get_movable()); BOOST_STATIC_ASSERT((boost::is_movable::value == true)); return 0; }