mirror of
https://github.com/boostorg/multiprecision.git
synced 2026-02-15 13:12:21 +00:00
Update tests to exercise move-construct/copy better.
Fix exposed bug in tommath backend. See also https://svn.boost.org/trac/boost/ticket/9497.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -1777,5 +1777,24 @@ void test()
|
||||
test_conditional(a, (a + 0));
|
||||
|
||||
test_signed_ops<Real>(boost::mpl::bool_<std::numeric_limits<Real>::is_signed>());
|
||||
//
|
||||
// Test move:
|
||||
//
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
Real m(static_cast<Real&&>(a));
|
||||
BOOST_CHECK_EQUAL(m, 20);
|
||||
// Move from already moved from object:
|
||||
Real m2(static_cast<Real&&>(a));
|
||||
// assign from moved from object
|
||||
// (may result in "a" being left in valid state as implementation artifact):
|
||||
c = static_cast<Real&&>(a);
|
||||
// assignment to moved-from objects:
|
||||
c = static_cast<Real&&>(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<Real&&>(a));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user