1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 04:57:45 +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() { return m_elements; }
constexpr Matrix operator*(Matrix const& other) const
[[nodiscard]] constexpr Matrix operator*(Matrix const& other) const
{
Matrix product;
for (size_t i = 0; i < N; ++i) {
@ -84,7 +84,7 @@ public:
return product;
}
constexpr Matrix operator+(Matrix const& other) const
[[nodiscard]] constexpr Matrix operator+(Matrix const& other) const
{
Matrix sum;
for (size_t i = 0; i < N; ++i) {
@ -94,7 +94,7 @@ public:
return sum;
}
constexpr Matrix operator/(T divisor) const
[[nodiscard]] constexpr Matrix operator/(T divisor) const
{
Matrix division;
for (size_t i = 0; i < N; ++i) {
@ -104,7 +104,7 @@ public:
return division;
}
friend constexpr Matrix operator*(Matrix const& matrix, T scalar)
[[nodiscard]] friend constexpr Matrix operator*(Matrix const& matrix, T scalar)
{
Matrix scaled;
for (size_t i = 0; i < N; ++i) {
@ -114,7 +114,7 @@ public:
return scaled;
}
friend constexpr Matrix operator*(T scalar, Matrix const& matrix)
[[nodiscard]] friend constexpr Matrix operator*(T scalar, Matrix const& matrix)
{
return matrix * scalar;
}