From a503fc87254aca625d7b128a2260599d40dc0889 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Wed, 18 Jul 2018 23:26:13 +0200 Subject: bug #1575: fix regression introduced in bug #1573 patch. Move ctor/assignment should not be defaulted. --- Eigen/src/Geometry/Quaternion.h | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) (limited to 'Eigen/src/Geometry') diff --git a/Eigen/src/Geometry/Quaternion.h b/Eigen/src/Geometry/Quaternion.h index 6fad6564a..8b203dc71 100644 --- a/Eigen/src/Geometry/Quaternion.h +++ b/Eigen/src/Geometry/Quaternion.h @@ -105,22 +105,6 @@ class QuaternionBase : public RotationBase EIGEN_DEVICE_FUNC Derived& operator=(const AngleAxisType& aa); template EIGEN_DEVICE_FUNC Derived& operator=(const MatrixBase& m); -#if EIGEN_HAS_RVALUE_REFERENCES - // Because we have a user-defined copy assignment operator, we don't get an implicit move constructor or assignment operator. - /** Default move constructor */ - EIGEN_DEVICE_FUNC inline QuaternionBase(QuaternionBase&& other) EIGEN_NOEXCEPT_IF(std::is_nothrow_move_constructible::value) = default; - - /** Default move assignment operator */ - EIGEN_DEVICE_FUNC QuaternionBase& operator=(QuaternionBase&& other) EIGEN_NOEXCEPT_IF(std::is_nothrow_move_assignable::value) = default; - - // And now because we declared a constructor, we don't get a default constructor or copy constructor. Say we want them. - /** Default constructor */ - EIGEN_DEVICE_FUNC QuaternionBase() = default; - - /** Copy constructor */ - EIGEN_DEVICE_FUNC QuaternionBase(const QuaternionBase& other) = default; -#endif - /** \returns a quaternion representing an identity rotation * \sa MatrixBase::Identity() */ @@ -295,14 +279,24 @@ public: #if EIGEN_HAS_RVALUE_REFERENCES // We define a copy constructor, which means we don't get an implicit move constructor or assignment operator. /** Default move constructor */ - EIGEN_DEVICE_FUNC inline Quaternion(Quaternion&& other) EIGEN_NOEXCEPT_IF(std::is_nothrow_move_constructible::value) = default; + EIGEN_DEVICE_FUNC inline Quaternion(Quaternion&& other) EIGEN_NOEXCEPT_IF(std::is_nothrow_move_constructible::value) + { + m_coeffs(std::move(other.coeffs())); + } /** Default move assignment operator */ - EIGEN_DEVICE_FUNC Quaternion& operator=(Quaternion&& other) EIGEN_NOEXCEPT_IF(std::is_nothrow_move_assignable::value) = default; + EIGEN_DEVICE_FUNC Quaternion& operator=(Quaternion&& other) EIGEN_NOEXCEPT_IF(std::is_nothrow_move_assignable::value) + { + m_coeffs = std::move(other.coeffs()); + return *this; + } // And now because we declared a constructor, we don't get an implicit copy constructor. Say we want one. /** Default copy constructor */ - EIGEN_DEVICE_FUNC Quaternion(const Quaternion& other) = default; + EIGEN_DEVICE_FUNC Quaternion(const Quaternion& other) + { + m_coeffs = other.coeffs(); + } #endif EIGEN_DEVICE_FUNC static Quaternion UnitRandom(); @@ -657,7 +651,7 @@ EIGEN_DEVICE_FUNC Quaternion Quaternion::UnitRan const Scalar u1 = internal::random(0, 1), u2 = internal::random(0, 2*EIGEN_PI), u3 = internal::random(0, 2*EIGEN_PI); - const Scalar a = sqrt(1 - u1), + const Scalar a = sqrt(Scalar(1) - u1), b = sqrt(u1); return Quaternion (a * sin(u2), a * cos(u2), b * sin(u3), b * cos(u3)); } -- cgit v1.2.3