diff options
author | Sean Harmer <sean.harmer@kdab.com> | 2013-08-16 17:57:38 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-08-27 17:50:40 +0200 |
commit | a70c0ad1d15e1346f7784f4e720bbe460af85c17 (patch) | |
tree | a5c2e1c59a2d2c1977d1cd922f15ccdfcb46696a /src/gui/math3d/qvector4d.h | |
parent | e0f2603f49b17eb4e562ec81e92796e3b2435490 (diff) |
Add operator[] to QVectorND classes
Change-Id: Ia786d4fab64da974bb60f24c05325925d42a1e70
Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Diffstat (limited to 'src/gui/math3d/qvector4d.h')
-rw-r--r-- | src/gui/math3d/qvector4d.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/gui/math3d/qvector4d.h b/src/gui/math3d/qvector4d.h index 4bd3822133..810380b805 100644 --- a/src/gui/math3d/qvector4d.h +++ b/src/gui/math3d/qvector4d.h @@ -82,6 +82,9 @@ public: void setZ(float z); void setW(float w); + float &operator[](int i); + float operator[](int i) const; + float length() const; float lengthSquared() const; @@ -158,6 +161,18 @@ inline void QVector4D::setY(float aY) { yp = aY; } inline void QVector4D::setZ(float aZ) { zp = aZ; } inline void QVector4D::setW(float aW) { wp = aW; } +inline float &QVector4D::operator[](int i) +{ + Q_ASSERT(uint(i) < 4u); + return *(&xp + i); +} + +inline float QVector4D::operator[](int i) const +{ + Q_ASSERT(uint(i) < 4u); + return *(&xp + i); +} + inline QVector4D &QVector4D::operator+=(const QVector4D &vector) { xp += vector.xp; |