From 4c9885a0f580c8273a211a92b6fc55af1d4f03c0 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Mon, 10 Mar 2014 11:26:42 +0100 Subject: [PATCH] Revert some previously added constexpr in QVector?d classes This commit partly reverts cd91d8ad0281c984a01b8091696a6fdfdfa69514. The revert is required as the used ifdef relied on undefined compiler behavior. Especially Windows has had trouble. The revert reduces the risk of breaks by future compilers. The proper inline and constexpr has to wait until Qt 6. Task-number: QTBUG-37122 Change-Id: I881fffb95fa46d9c170c9420a578f15640e18aea Reviewed-by: Lars Knoll --- src/gui/math3d/qvector2d.cpp | 2 -- src/gui/math3d/qvector2d.h | 14 ++------------ src/gui/math3d/qvector3d.cpp | 4 ---- src/gui/math3d/qvector3d.h | 14 +++----------- src/gui/math3d/qvector4d.cpp | 2 -- src/gui/math3d/qvector4d.h | 14 ++------------ 6 files changed, 7 insertions(+), 43 deletions(-) diff --git a/src/gui/math3d/qvector2d.cpp b/src/gui/math3d/qvector2d.cpp index 73999f1fca9..a56e23eb72d 100644 --- a/src/gui/math3d/qvector2d.cpp +++ b/src/gui/math3d/qvector2d.cpp @@ -326,12 +326,10 @@ float QVector2D::distanceToLine /*! Returns the dot product of \a v1 and \a v2. */ -#if defined(QT_BUILD_GUI_LIB) && !defined(QT_STATIC) float QVector2D::dotProduct(const QVector2D& v1, const QVector2D& v2) { return v1.xp * v2.xp + v1.yp * v2.yp; } -#endif /*! \fn bool operator==(const QVector2D &v1, const QVector2D &v2) diff --git a/src/gui/math3d/qvector2d.h b/src/gui/math3d/qvector2d.h index 0098c119eca..bd1d28274cc 100644 --- a/src/gui/math3d/qvector2d.h +++ b/src/gui/math3d/qvector2d.h @@ -80,12 +80,7 @@ public: float operator[](int i) const; float length() const; -#ifdef QT_BUILD_GUI_LIB - float lengthSquared() const; -#else - Q_DECL_CONSTEXPR inline float lengthSquared() const - { return xp * xp + yp * yp; } -#endif + float lengthSquared() const; //In Qt 6 convert to inline and constexpr QVector2D normalized() const; void normalize(); @@ -99,12 +94,7 @@ public: QVector2D &operator*=(const QVector2D &vector); QVector2D &operator/=(float divisor); -#if defined(QT_BUILD_GUI_LIB) && !defined(QT_STATIC) - static float dotProduct(const QVector2D& v1, const QVector2D& v2); -#else - Q_DECL_CONSTEXPR inline static float dotProduct(const QVector2D& v1, const QVector2D& v2) - { return v1.xp * v2.xp + v1.yp * v2.yp; } -#endif + static float dotProduct(const QVector2D& v1, const QVector2D& v2); //In Qt 6 convert to inline and constexpr Q_DECL_CONSTEXPR friend inline bool operator==(const QVector2D &v1, const QVector2D &v2); Q_DECL_CONSTEXPR friend inline bool operator!=(const QVector2D &v1, const QVector2D &v2); diff --git a/src/gui/math3d/qvector3d.cpp b/src/gui/math3d/qvector3d.cpp index 1cb73a1fa20..7e3ed7c61bf 100644 --- a/src/gui/math3d/qvector3d.cpp +++ b/src/gui/math3d/qvector3d.cpp @@ -316,12 +316,10 @@ void QVector3D::normalize() /*! Returns the dot product of \a v1 and \a v2. */ -#if defined(QT_BUILD_GUI_LIB) && !defined(QT_STATIC) float QVector3D::dotProduct(const QVector3D& v1, const QVector3D& v2) { return v1.xp * v2.xp + v1.yp * v2.yp + v1.zp * v2.zp; } -#endif /*! Returns the cross-product of vectors \a v1 and \a v2, which corresponds @@ -329,14 +327,12 @@ float QVector3D::dotProduct(const QVector3D& v1, const QVector3D& v2) \sa normal() */ -#if defined(QT_BUILD_GUI_LIB) && !defined(QT_STATIC) QVector3D QVector3D::crossProduct(const QVector3D& v1, const QVector3D& v2) { return QVector3D(v1.yp * v2.zp - v1.zp * v2.yp, v1.zp * v2.xp - v1.xp * v2.zp, v1.xp * v2.yp - v1.yp * v2.xp); } -#endif /*! Returns the normal vector of a plane defined by vectors \a v1 and \a v2, diff --git a/src/gui/math3d/qvector3d.h b/src/gui/math3d/qvector3d.h index 64f8e347046..51412a940ab 100644 --- a/src/gui/math3d/qvector3d.h +++ b/src/gui/math3d/qvector3d.h @@ -95,17 +95,9 @@ public: QVector3D &operator*=(const QVector3D& vector); QVector3D &operator/=(float divisor); -#if defined(QT_BUILD_GUI_LIB) && !defined(QT_STATIC) - static float dotProduct(const QVector3D& v1, const QVector3D& v2); - static QVector3D crossProduct(const QVector3D& v1, const QVector3D& v2); -#else - Q_DECL_CONSTEXPR inline static float dotProduct(const QVector3D& v1, const QVector3D& v2) - { return v1.xp * v2.xp + v1.yp * v2.yp + v1.zp * v2.zp; } - Q_DECL_CONSTEXPR inline static QVector3D crossProduct(const QVector3D& v1, const QVector3D& v2) - { return QVector3D(v1.yp * v2.zp - v1.zp * v2.yp, - v1.zp * v2.xp - v1.xp * v2.zp, - v1.xp * v2.yp - v1.yp * v2.xp); } -#endif + static float dotProduct(const QVector3D& v1, const QVector3D& v2); //In Qt 6 convert to inline and constexpr + static QVector3D crossProduct(const QVector3D& v1, const QVector3D& v2); //in Qt 6 convert to inline and constexpr + static QVector3D normal(const QVector3D& v1, const QVector3D& v2); static QVector3D normal (const QVector3D& v1, const QVector3D& v2, const QVector3D& v3); diff --git a/src/gui/math3d/qvector4d.cpp b/src/gui/math3d/qvector4d.cpp index b3db610d9af..691551367f9 100644 --- a/src/gui/math3d/qvector4d.cpp +++ b/src/gui/math3d/qvector4d.cpp @@ -369,12 +369,10 @@ void QVector4D::normalize() /*! Returns the dot product of \a v1 and \a v2. */ -#if defined(QT_BUILD_GUI_LIB) && !defined(QT_STATIC) float QVector4D::dotProduct(const QVector4D& v1, const QVector4D& v2) { return v1.xp * v2.xp + v1.yp * v2.yp + v1.zp * v2.zp + v1.wp * v2.wp; } -#endif /*! \fn bool operator==(const QVector4D &v1, const QVector4D &v2) diff --git a/src/gui/math3d/qvector4d.h b/src/gui/math3d/qvector4d.h index 2bc5b79c14c..9ab0eba09f9 100644 --- a/src/gui/math3d/qvector4d.h +++ b/src/gui/math3d/qvector4d.h @@ -86,12 +86,7 @@ public: float operator[](int i) const; float length() const; -#ifdef QT_BUILD_GUI_LIB - float lengthSquared() const; -#else - Q_DECL_CONSTEXPR inline float lengthSquared() const - { return xp * xp + yp * yp + zp * zp + wp * wp; } -#endif + float lengthSquared() const; //In Qt 6 convert to inline and constexpr QVector4D normalized() const; void normalize(); @@ -102,12 +97,7 @@ public: QVector4D &operator*=(const QVector4D &vector); QVector4D &operator/=(float divisor); -#if defined(QT_BUILD_GUI_LIB) && !defined(QT_STATIC) - static float dotProduct(const QVector4D& v1, const QVector4D& v2); -#else - static float dotProduct(const QVector4D& v1, const QVector4D& v2) - { return v1.xp * v2.xp + v1.yp * v2.yp + v1.zp * v2.zp + v1.wp * v2.wp; } -#endif + static float dotProduct(const QVector4D& v1, const QVector4D& v2); //In Qt 6 convert to inline and constexpr Q_DECL_CONSTEXPR friend inline bool operator==(const QVector4D &v1, const QVector4D &v2); Q_DECL_CONSTEXPR friend inline bool operator!=(const QVector4D &v1, const QVector4D &v2);