[libcxx-commits] [libcxx] [libc++][NFC] Simplify `gcd` a bit (PR #173570)

A. Jiang via libcxx-commits libcxx-commits at lists.llvm.org
Sun Dec 28 17:31:11 PST 2025


================
@@ -33,28 +33,25 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 #if _LIBCPP_STD_VER >= 17
 
-template <typename _Result, typename _Source, bool _IsSigned = is_signed<_Source>::value>
-struct __ct_abs;
-
-template <typename _Result, typename _Source>
-struct __ct_abs<_Result, _Source, true> {
-  constexpr _LIBCPP_HIDE_FROM_ABI _Result operator()(_Source __t) const noexcept {
+template <class _Result, class _Source>
+constexpr _LIBCPP_HIDE_FROM_ABI _Result __abs_in_type(_Source __t) noexcept {
+  if constexpr (is_signed_v<_Source>) {
     if (__t >= 0)
       return __t;
     if (__t == numeric_limits<_Source>::min())
       return -static_cast<_Result>(__t);
     return -__t;
-  }
-};
-
-template <typename _Result, typename _Source>
-struct __ct_abs<_Result, _Source, false> {
-  constexpr _LIBCPP_HIDE_FROM_ABI _Result operator()(_Source __t) const noexcept { return __t; }
-};
+  } else
----------------
frederick-vs-ja wrote:

Added.

https://github.com/llvm/llvm-project/pull/173570


More information about the libcxx-commits mailing list