浏览代码

LibGfx: Templatize `VectorN::length()`

This allows us to get a `float` length from an `IntVector3` without
needing to convert to `FloatVector3` first.
Jelle Raaijmakers 2 年之前
父节点
当前提交
16ca9ec762
共有 1 个文件被更改,包括 3 次插入2 次删除
  1. 3 2
      Userland/Libraries/LibGfx/VectorN.h

+ 3 - 2
Userland/Libraries/LibGfx/VectorN.h

@@ -205,9 +205,10 @@ public:
         operator*=(inv_length);
     }
 
-    [[nodiscard]] constexpr T length() const
+    template<typename O = T>
+    [[nodiscard]] constexpr O length() const
     {
-        return AK::sqrt(dot(*this));
+        return AK::sqrt<O>(dot(*this));
     }
 
     [[nodiscard]] constexpr VectorN<2, T> xy() const requires(N >= 3)