#include <boost/move/detail/meta_utils_core.hpp>
#include <boost/move/move.hpp>
class Foo
{
BOOST_COPYABLE_AND_MOVABLE(Foo)
public:
int i;
explicit Foo(int val) : i(val) {}
Foo(BOOST_RV_REF(Foo) obj) : i(obj.i) {}
Foo& operator=(BOOST_RV_REF(Foo) rhs)
{ i = rhs.i; rhs.i = 0; return *this; }
Foo& operator=(BOOST_COPY_ASSIGN_REF(Foo) rhs)
{ i = rhs.i; return *this; }
template<class U> #if 1
typename ::boost::move_detail::disable_if_same<U, Foo, Foo&>::type
operator=(const U& rhs)
#else
Foo& operator=(const U& rhs)
#endif
{ i = -rhs.i; return *this; } };
struct Bar
{
int i;
explicit Bar(int val) : i(val) {}
};
#ifdef NDEBUG
#undef NDEBUG
#endif
#include <cassert>
int main()
{
Foo foo1(1);
assert(foo1.i == 1);
Foo foo2(2);
assert(foo2.i == 2);
Bar bar(3);
assert(bar.i == 3);
foo2 = foo1; assert(foo2.i == 1);
assert(foo1.i == 1); foo1 = bar;
assert(foo1.i == -3);
foo2 = boost::move(foo1);
assert(foo1.i == 0);
assert(foo2.i == -3);
const Foo foo5(5);
foo2 = foo5; assert(foo2.i == 5); assert(foo5.i == 5);
return 0;
}