diff options
author | Gael Guennebaud <g.gael@free.fr> | 2018-07-17 11:11:33 +0200 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2018-07-17 11:11:33 +0200 |
commit | 2b2cd85694c7d340eb8b3d3ba944d33360666381 (patch) | |
tree | 4690fdb37f827ba861ab4413b3a7e6aef480f098 | |
parent | 43206ac4de09e348aaf0c8e7134f59872eaf55f4 (diff) |
bug #1573: add noexcept move constructor and move assignment operator to Quaternion
-rw-r--r-- | Eigen/src/Geometry/Quaternion.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/Eigen/src/Geometry/Quaternion.h b/Eigen/src/Geometry/Quaternion.h index c3fd8c3e0..6fad6564a 100644 --- a/Eigen/src/Geometry/Quaternion.h +++ b/Eigen/src/Geometry/Quaternion.h @@ -105,6 +105,22 @@ class QuaternionBase : public RotationBase<Derived, 3> EIGEN_DEVICE_FUNC Derived& operator=(const AngleAxisType& aa); template<class OtherDerived> EIGEN_DEVICE_FUNC Derived& operator=(const MatrixBase<OtherDerived>& 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<Scalar>::value) = default; + + /** Default move assignment operator */ + EIGEN_DEVICE_FUNC QuaternionBase& operator=(QuaternionBase&& other) EIGEN_NOEXCEPT_IF(std::is_nothrow_move_assignable<Scalar>::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() */ @@ -276,6 +292,19 @@ public: EIGEN_DEVICE_FUNC explicit inline Quaternion(const Quaternion<OtherScalar, OtherOptions>& other) { m_coeffs = other.coeffs().template cast<Scalar>(); } +#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<Scalar>::value) = default; + + /** Default move assignment operator */ + EIGEN_DEVICE_FUNC Quaternion& operator=(Quaternion&& other) EIGEN_NOEXCEPT_IF(std::is_nothrow_move_assignable<Scalar>::value) = default; + + // 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; +#endif + EIGEN_DEVICE_FUNC static Quaternion UnitRandom(); template<typename Derived1, typename Derived2> |