From 7cb1cc8ab5f525b3f0cb3fb6681f66ff17dd07ae Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Fri, 23 Oct 2020 18:40:54 -0700 Subject: [PATCH] Add some constexpr --- common/vecmat.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/common/vecmat.h b/common/vecmat.h index 7186ec6c..dbf51009 100644 --- a/common/vecmat.h +++ b/common/vecmat.h @@ -58,7 +58,7 @@ public: : mVals{{{{aa, ab, ac, ad}}, {{ba, bb, bc, bd}}, {{ca, cb, cc, cd}}, {{da, db, dc, dd}}}} { } - std::array& operator[](size_t idx) noexcept { return mVals[idx]; } + constexpr std::array& operator[](size_t idx) noexcept { return mVals[idx]; } constexpr const std::array& operator[](size_t idx) const noexcept { return mVals[idx]; } void setRow(size_t idx, float a, float b, float c, float d) noexcept @@ -69,15 +69,14 @@ public: mVals[idx][3] = d; } - static const Matrix &Identity() noexcept + static constexpr Matrix Identity() noexcept { - static constexpr Matrix identity{ + return Matrix{ 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f }; - return identity; } }; -- 2.11.4.GIT