diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-10-27 23:59:16 +0100 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-10-29 08:51:44 +0100 |
commit | 7372dde4ec6cb32448ea026f48b5f5ea517f778d (patch) | |
tree | 3600af1e40442b8ff5a320c60cf37427848fb4b8 /src/gui/math3d/qvector4d.h | |
parent | 2222e695fcb547ed6c08f290b3b34bf36013eaad (diff) |
Math 3D classes: make comparison operators hidden friends
Reduce ADL noise from QVector2/3/4D and from QQuaternion. Also mark as
noexcept.
Task-number: QTBUG-87973
Change-Id: Id14fd17c0da43517766b218ed85c3b41f91b43c8
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/gui/math3d/qvector4d.h')
-rw-r--r-- | src/gui/math3d/qvector4d.h | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/src/gui/math3d/qvector4d.h b/src/gui/math3d/qvector4d.h index 4165ec25ef..327c6f01d3 100644 --- a/src/gui/math3d/qvector4d.h +++ b/src/gui/math3d/qvector4d.h @@ -100,8 +100,19 @@ public: static float dotProduct(const QVector4D& v1, const QVector4D& v2); //In Qt 6 convert to inline and constexpr - constexpr friend inline bool operator==(const QVector4D &v1, const QVector4D &v2); - constexpr friend inline bool operator!=(const QVector4D &v1, const QVector4D &v2); +QT_WARNING_PUSH +QT_WARNING_DISABLE_FLOAT_COMPARE + constexpr friend inline bool operator==(const QVector4D &v1, const QVector4D &v2) noexcept + { + return v1.v[0] == v2.v[0] && v1.v[1] == v2.v[1] && v1.v[2] == v2.v[2] && v1.v[3] == v2.v[3]; + } + + constexpr friend inline bool operator!=(const QVector4D &v1, const QVector4D &v2) noexcept + { + return v1.v[0] != v2.v[0] || v1.v[1] != v2.v[1] || v1.v[2] != v2.v[2] || v1.v[3] != v2.v[3]; + } +QT_WARNING_POP + constexpr friend inline const QVector4D operator+(const QVector4D &v1, const QVector4D &v2); constexpr friend inline const QVector4D operator-(const QVector4D &v1, const QVector4D &v2); constexpr friend inline const QVector4D operator*(float factor, const QVector4D &vector); @@ -229,20 +240,6 @@ inline QVector4D &QVector4D::operator/=(const QVector4D &vector) return *this; } -QT_WARNING_PUSH -QT_WARNING_DISABLE_FLOAT_COMPARE - -constexpr inline bool operator==(const QVector4D &v1, const QVector4D &v2) -{ - return v1.v[0] == v2.v[0] && v1.v[1] == v2.v[1] && v1.v[2] == v2.v[2] && v1.v[3] == v2.v[3]; -} - -constexpr inline bool operator!=(const QVector4D &v1, const QVector4D &v2) -{ - return v1.v[0] != v2.v[0] || v1.v[1] != v2.v[1] || v1.v[2] != v2.v[2] || v1.v[3] != v2.v[3]; -} -QT_WARNING_POP - constexpr inline const QVector4D operator+(const QVector4D &v1, const QVector4D &v2) { return QVector4D(v1.v[0] + v2.v[0], v1.v[1] + v2.v[1], v1.v[2] + v2.v[2], v1.v[3] + v2.v[3]); |