1 //////////////////////////////////////////////////////////////////////////////
3 // (C) Copyright Ion Gaztanaga 2009.
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/config.hpp>
14 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
23 #include <boost/move/detail/config_begin.hpp>
26 #include <boost/move/core.hpp>
31 public: //conversions provided by BOOST_COPYABLE_AND_MOVABLE
32 operator ::boost::rv<sink_tester>&()
33 { return *static_cast< ::boost::rv<sink_tester>* >(this); }
34 operator const ::boost::rv<sink_tester>&() const
35 { return *static_cast<const ::boost::rv<sink_tester>* >(this); }
38 //Functions returning different r/lvalue types
39 sink_tester rvalue() { return sink_tester(); }
40 const sink_tester const_rvalue() { return sink_tester(); }
41 sink_tester & lvalue() { static sink_tester lv; return lv; }
42 const sink_tester & const_lvalue() { static const sink_tester clv = sink_tester(); return clv; }
44 //BOOST_RV_REF overload
45 void sink(::boost::rv<sink_tester> &) { std::cout << "non-const rvalue catched" << std::endl; }
46 //BOOST_COPY_ASSIGN_REF overload
47 void sink(const ::boost::rv<sink_tester> &){ std::cout << "const (r-l)value catched" << std::endl; }
48 //Overload provided by BOOST_COPYABLE_AND_MOVABLE
49 void sink(sink_tester &) { std::cout << "non-const lvalue catched" << std::endl; }
53 sink(const_rvalue()); //"const (r-l)value catched"
54 sink(const_lvalue()); //"const (r-l)value catched"
55 sink(lvalue()); //"non-const lvalue catched"
56 sink(rvalue()); //"non-const rvalue catched"
61 #include <boost/move/detail/config_end.hpp>