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

LibGfx: Allow Vector{2,3,4} operators to accept different argument types

This is needed to e.g. multiply a Vector4<f32x4> by a float.
This commit is contained in:
Stephan Unverwerth 2022-01-01 17:33:48 +01:00 committed by Ali Mohammad Pur
parent 486d2d099c
commit b07bb85700
3 changed files with 12 additions and 6 deletions

View file

@ -60,12 +60,14 @@ public:
return Vector2(m_x / other.m_x, m_y / other.m_y);
}
constexpr Vector2 operator*(T f) const
template<typename U>
constexpr Vector2 operator*(U f) const
{
return Vector2(m_x * f, m_y * f);
}
constexpr Vector2 operator/(T f) const
template<typename U>
constexpr Vector2 operator/(U f) const
{
return Vector2(m_x / f, m_y / f);
}

View file

@ -65,12 +65,14 @@ public:
return Vector3(m_x / other.m_x, m_y / other.m_y, m_z / other.m_z);
}
constexpr Vector3 operator*(T f) const
template<typename U>
constexpr Vector3 operator*(U f) const
{
return Vector3(m_x * f, m_y * f, m_z * f);
}
constexpr Vector3 operator/(T f) const
template<typename U>
constexpr Vector3 operator/(U f) const
{
return Vector3(m_x / f, m_y / f, m_z / f);
}

View file

@ -70,12 +70,14 @@ public:
return Vector4(m_x / other.m_x, m_y / other.m_y, m_z / other.m_z, m_w / other.m_w);
}
constexpr Vector4 operator*(T f) const
template<typename U>
constexpr Vector4 operator*(U f) const
{
return Vector4(m_x * f, m_y * f, m_z * f, m_w * f);
}
constexpr Vector4 operator/(T f) const
template<typename U>
constexpr Vector4 operator/(U f) const
{
return Vector4(m_x / f, m_y / f, m_z / f, m_w / f);
}