[libcxx-commits] [libcxx] [libc++] std::abs support for _BitInt(N) and __int128 (PR #196532)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jun 16 07:03:59 PDT 2026


================
@@ -63,6 +65,18 @@ template <class = int>
   return __builtin_llabs(__x);
 }
 
+// Covers __int128 and signed _BitInt(N) with sizeof >= sizeof(int).
+// The int/long/long long exclusions are load-bearing: _BitInt(33..64)
+// shares sizeof with long long and would otherwise compete with the
+// builtin overload.
+template <class _Tp,
+          __enable_if_t<__is_signed_integer_v<_Tp> && !is_same<_Tp, int>::value && !is_same<_Tp, long>::value &&
----------------
philnik777 wrote:

I think I'd rather split this into two `__int128` overloads and an explicit `abs(_BitInt(N) v)`. That way we avoid this funky constraint.

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


More information about the libcxx-commits mailing list