From cd91d8ad0281c984a01b8091696a6fdfdfa69514 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Fri, 15 Nov 2013 13:47:24 +0100 Subject: Convert more QVector*D member functions to constexpr constexpr requires inline functions. We convert more member functions to inline functions while retaining a version of those functions inside QtGui. This prevents any BC breakage. Change-Id: I325b78da6b41611bda3994869f474c700b6fb306 Reviewed-by: Marc Mutz Reviewed-by: Lars Knoll --- src/gui/math3d/qvector2d.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/gui/math3d/qvector2d.h') diff --git a/src/gui/math3d/qvector2d.h b/src/gui/math3d/qvector2d.h index b40c8ed783..649d45d477 100644 --- a/src/gui/math3d/qvector2d.h +++ b/src/gui/math3d/qvector2d.h @@ -80,7 +80,12 @@ 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 QVector2D normalized() const; void normalize(); @@ -94,7 +99,12 @@ public: QVector2D &operator*=(const QVector2D &vector); QVector2D &operator/=(float divisor); +#ifdef QT_BUILD_GUI_LIB 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 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); -- cgit v1.2.3