From 16ca9ec762974e75b88855e5fe44c18b22c032dc Mon Sep 17 00:00:00 2001 From: Jelle Raaijmakers Date: Sat, 10 Sep 2022 14:17:24 +0200 Subject: [PATCH] LibGfx: Templatize `VectorN::length()` This allows us to get a `float` length from an `IntVector3` without needing to convert to `FloatVector3` first. --- Userland/Libraries/LibGfx/VectorN.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibGfx/VectorN.h b/Userland/Libraries/LibGfx/VectorN.h index 758f6e9d8e..bf8eecc518 100644 --- a/Userland/Libraries/LibGfx/VectorN.h +++ b/Userland/Libraries/LibGfx/VectorN.h @@ -205,9 +205,10 @@ public: operator*=(inv_length); } - [[nodiscard]] constexpr T length() const + template + [[nodiscard]] constexpr O length() const { - return AK::sqrt(dot(*this)); + return AK::sqrt(dot(*this)); } [[nodiscard]] constexpr VectorN<2, T> xy() const requires(N >= 3)