diff options
author | Marc Mutz <marc.mutz@qt.io> | 2023-03-15 08:11:31 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2023-03-16 00:46:28 +0100 |
commit | 49e5f2190830e27e25b57fd12d8c3b99a5c82a23 (patch) | |
tree | 94380a7964db9ccbe6a8d7393d6f643045dde670 /src/gui/math3d | |
parent | 09c3cd8503102c70c7d5bf41c0b662b2c86b4ad0 (diff) |
QVector<N>D: simplify get<I>() implementation
instead of if (I == x) return ~~~[x]; just always return ~~~[I].
Pick-to: 6.5
Change-Id: I236159480ab90201f7e3f6f90fdcd1cab5d3a223
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/gui/math3d')
-rw-r--r-- | src/gui/math3d/qvectornd.h | 21 |
1 files changed, 3 insertions, 18 deletions
diff --git a/src/gui/math3d/qvectornd.h b/src/gui/math3d/qvectornd.h index b5985a8d11..0f3ce758a8 100644 --- a/src/gui/math3d/qvectornd.h +++ b/src/gui/math3d/qvectornd.h @@ -148,10 +148,7 @@ private: std::enable_if_t<std::is_same_v<std::decay_t<V>, QVector2D>, bool> = true> friend constexpr decltype(auto) get(V &&vec) noexcept { - if constexpr (I == 0) - return (std::forward<V>(vec).v[0]); - else if constexpr (I == 1) - return (std::forward<V>(vec).v[1]); + return (std::forward<V>(vec).v[I]); } }; @@ -310,12 +307,7 @@ private: std::enable_if_t<std::is_same_v<std::decay_t<V>, QVector3D>, bool> = true> friend constexpr decltype(auto) get(V &&vec) noexcept { - if constexpr (I == 0) - return (std::forward<V>(vec).v[0]); - else if constexpr (I == 1) - return (std::forward<V>(vec).v[1]); - else if constexpr (I == 2) - return (std::forward<V>(vec).v[2]); + return (std::forward<V>(vec).v[I]); } }; @@ -467,14 +459,7 @@ private: std::enable_if_t<std::is_same_v<std::decay_t<V>, QVector4D>, bool> = true> friend constexpr decltype(auto) get(V &&vec) noexcept { - if constexpr (I == 0) - return (std::forward<V>(vec).v[0]); - else if constexpr (I == 1) - return (std::forward<V>(vec).v[1]); - else if constexpr (I == 2) - return (std::forward<V>(vec).v[2]); - else if constexpr (I == 3) - return (std::forward<V>(vec).v[3]); + return (std::forward<V>(vec).v[I]); } }; |