Skip to content

Commit a503fc8

Browse files
committed
bug #1575: fix regression introduced in bug #1573 patch. Move ctor/assignment should not be defaulted.
1 parent 308725c commit a503fc8

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

Eigen/src/Geometry/Quaternion.h

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -105,22 +105,6 @@ class QuaternionBase : public RotationBase<Derived, 3>
105105
EIGEN_DEVICE_FUNC Derived& operator=(const AngleAxisType& aa);
106106
template<class OtherDerived> EIGEN_DEVICE_FUNC Derived& operator=(const MatrixBase<OtherDerived>& m);
107107

108-
#if EIGEN_HAS_RVALUE_REFERENCES
109-
// Because we have a user-defined copy assignment operator, we don't get an implicit move constructor or assignment operator.
110-
/** Default move constructor */
111-
EIGEN_DEVICE_FUNC inline QuaternionBase(QuaternionBase&& other) EIGEN_NOEXCEPT_IF(std::is_nothrow_move_constructible<Scalar>::value) = default;
112-
113-
/** Default move assignment operator */
114-
EIGEN_DEVICE_FUNC QuaternionBase& operator=(QuaternionBase&& other) EIGEN_NOEXCEPT_IF(std::is_nothrow_move_assignable<Scalar>::value) = default;
115-
116-
// And now because we declared a constructor, we don't get a default constructor or copy constructor. Say we want them.
117-
/** Default constructor */
118-
EIGEN_DEVICE_FUNC QuaternionBase() = default;
119-
120-
/** Copy constructor */
121-
EIGEN_DEVICE_FUNC QuaternionBase(const QuaternionBase& other) = default;
122-
#endif
123-
124108
/** \returns a quaternion representing an identity rotation
125109
* \sa MatrixBase::Identity()
126110
*/
@@ -295,14 +279,24 @@ class Quaternion : public QuaternionBase<Quaternion<_Scalar,_Options> >
295279
#if EIGEN_HAS_RVALUE_REFERENCES
296280
// We define a copy constructor, which means we don't get an implicit move constructor or assignment operator.
297281
/** Default move constructor */
298-
EIGEN_DEVICE_FUNC inline Quaternion(Quaternion&& other) EIGEN_NOEXCEPT_IF(std::is_nothrow_move_constructible<Scalar>::value) = default;
282+
EIGEN_DEVICE_FUNC inline Quaternion(Quaternion&& other) EIGEN_NOEXCEPT_IF(std::is_nothrow_move_constructible<Scalar>::value)
283+
{
284+
m_coeffs(std::move(other.coeffs()));
285+
}
299286

300287
/** Default move assignment operator */
301-
EIGEN_DEVICE_FUNC Quaternion& operator=(Quaternion&& other) EIGEN_NOEXCEPT_IF(std::is_nothrow_move_assignable<Scalar>::value) = default;
288+
EIGEN_DEVICE_FUNC Quaternion& operator=(Quaternion&& other) EIGEN_NOEXCEPT_IF(std::is_nothrow_move_assignable<Scalar>::value)
289+
{
290+
m_coeffs = std::move(other.coeffs());
291+
return *this;
292+
}
302293

303294
// And now because we declared a constructor, we don't get an implicit copy constructor. Say we want one.
304295
/** Default copy constructor */
305-
EIGEN_DEVICE_FUNC Quaternion(const Quaternion& other) = default;
296+
EIGEN_DEVICE_FUNC Quaternion(const Quaternion& other)
297+
{
298+
m_coeffs = other.coeffs();
299+
}
306300
#endif
307301

308302
EIGEN_DEVICE_FUNC static Quaternion UnitRandom();
@@ -657,7 +651,7 @@ EIGEN_DEVICE_FUNC Quaternion<Scalar,Options> Quaternion<Scalar,Options>::UnitRan
657651
const Scalar u1 = internal::random<Scalar>(0, 1),
658652
u2 = internal::random<Scalar>(0, 2*EIGEN_PI),
659653
u3 = internal::random<Scalar>(0, 2*EIGEN_PI);
660-
const Scalar a = sqrt(1 - u1),
654+
const Scalar a = sqrt(Scalar(1) - u1),
661655
b = sqrt(u1);
662656
return Quaternion (a * sin(u2), a * cos(u2), b * sin(u3), b * cos(u3));
663657
}

0 commit comments

Comments
 (0)