#include "movable.hpp"
#include "copymovable.hpp"
#include <boost/move/core.hpp>
template<class Type>
struct factory_functor
{
typedef Type return_type;
Type operator()() const
{ Type t; return BOOST_MOVE_RET(Type, t); }
};
struct return_reference
{
typedef non_copy_movable &return_type;
non_copy_movable &operator()() const
{ return ncm; }
static non_copy_movable ncm;
};
non_copy_movable return_reference::ncm;
template <class Factory>
typename Factory::return_type lock_wrapper(Factory f)
{
typedef typename Factory::return_type return_type;
return_type r = f();
return BOOST_MOVE_RET(return_type, r);
}
int main()
{
movable m = lock_wrapper(factory_functor<movable> ());
copy_movable cm = lock_wrapper(factory_functor<copy_movable>());
copyable c = lock_wrapper(factory_functor<copyable> ());
non_copy_movable &mr = lock_wrapper(return_reference ());
boost::movelib::ignore(m); boost::movelib::ignore(cm); boost::movelib::ignore(c); boost::movelib::ignore(mr);
return 0;
}