[libcxx-commits] [libcxx] [libc++] Implement std::gcd using the binary version (PR #77747)
via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Apr 24 14:40:17 PDT 2024
================
@@ -48,6 +49,68 @@ constexpr bool test0(int in1, int in2, int out)
return true;
}
+template <typename T>
+T basic_gcd_(T m, T n) {
+ return n == 0 ? m : basic_gcd_<T>(n, m % n);
+}
+
+template <typename T>
+T basic_gcd(T m, T n) {
+ using Tp = std::make_unsigned_t<T>;
+ if (m < 0 && m != std::numeric_limits<T>::min())
+ m = -m;
+ if (n < 0 && n != std::numeric_limits<T>::min())
+ n = -n;
----------------
AdvenamTacet wrote:
I see it's done.
https://github.com/llvm/llvm-project/pull/77747
More information about the libcxx-commits
mailing list