1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 12:17:44 +00:00

LibGfx: Add [[nodiscard]] to Matrix operators

This commit is contained in:
MacDue 2022-10-02 14:47:39 +01:00 committed by Andreas Kling
parent 3d532571bb
commit 6b167c8427

View file

@ -50,7 +50,7 @@ public:
constexpr auto elements() const { return m_elements; } constexpr auto elements() const { return m_elements; }
constexpr auto elements() { return m_elements; } constexpr auto elements() { return m_elements; }
constexpr Matrix operator*(Matrix const& other) const [[nodiscard]] constexpr Matrix operator*(Matrix const& other) const
{ {
Matrix product; Matrix product;
for (size_t i = 0; i < N; ++i) { for (size_t i = 0; i < N; ++i) {
@ -84,7 +84,7 @@ public:
return product; return product;
} }
constexpr Matrix operator+(Matrix const& other) const [[nodiscard]] constexpr Matrix operator+(Matrix const& other) const
{ {
Matrix sum; Matrix sum;
for (size_t i = 0; i < N; ++i) { for (size_t i = 0; i < N; ++i) {
@ -94,7 +94,7 @@ public:
return sum; return sum;
} }
constexpr Matrix operator/(T divisor) const [[nodiscard]] constexpr Matrix operator/(T divisor) const
{ {
Matrix division; Matrix division;
for (size_t i = 0; i < N; ++i) { for (size_t i = 0; i < N; ++i) {
@ -104,7 +104,7 @@ public:
return division; return division;
} }
friend constexpr Matrix operator*(Matrix const& matrix, T scalar) [[nodiscard]] friend constexpr Matrix operator*(Matrix const& matrix, T scalar)
{ {
Matrix scaled; Matrix scaled;
for (size_t i = 0; i < N; ++i) { for (size_t i = 0; i < N; ++i) {
@ -114,7 +114,7 @@ public:
return scaled; return scaled;
} }
friend constexpr Matrix operator*(T scalar, Matrix const& matrix) [[nodiscard]] friend constexpr Matrix operator*(T scalar, Matrix const& matrix)
{ {
return matrix * scalar; return matrix * scalar;
} }