diff --git a/include/boost/multiprecision/tommath.hpp b/include/boost/multiprecision/tommath.hpp index 17094434..85a7551e 100644 --- a/include/boost/multiprecision/tommath.hpp +++ b/include/boost/multiprecision/tommath.hpp @@ -58,7 +58,7 @@ struct tommath_int } tommath_int& operator = (tommath_int&& o) { - mp_exch(&m_data, &o.data()); + mp_exch(&m_data, &o.m_data); return *this; } #endif diff --git a/test/test_arithmetic.hpp b/test/test_arithmetic.hpp index a34d6247..3b6703ff 100644 --- a/test/test_arithmetic.hpp +++ b/test/test_arithmetic.hpp @@ -1777,5 +1777,24 @@ void test() test_conditional(a, (a + 0)); test_signed_ops(boost::mpl::bool_::is_signed>()); + // + // Test move: + // +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + Real m(static_cast(a)); + BOOST_CHECK_EQUAL(m, 20); + // Move from already moved from object: + Real m2(static_cast(a)); + // assign from moved from object + // (may result in "a" being left in valid state as implementation artifact): + c = static_cast(a); + // assignment to moved-from objects: + c = static_cast(m); + BOOST_CHECK_EQUAL(c, 20); + m2 = c; + BOOST_CHECK_EQUAL(c, 20); + // Destructor of "a" checks destruction of moved-from-object... + Real m3(static_cast(a)); +#endif }