[libcxx-commits] [libcxx] [libc++] std::abs support for _BitInt(N) and __int128 (PR #196532)
A. Jiang via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Jun 19 05:38:33 PDT 2026
================
@@ -37,6 +37,68 @@ void test_big() {
assert(std::abs(negative_big_value) == big_value); // make sure it doesn't get casted to a smaller type
}
+// std::abs has __int128/_BitInt(N) overloads as a libc++ extension. The
+// decltype-SFINAE probes below need C++11.
+#if TEST_STD_VER >= 11
+// Narrow signed types stay on the abs(int) promotion path.
+template <class T>
+struct unpromoted_abs : std::is_same<decltype(std::abs(T(0))), T> {};
+static_assert(!unpromoted_abs<signed char>::value, "");
+static_assert(!unpromoted_abs<short>::value, "");
+
+# ifdef __BITINT_MAXWIDTH__
----------------
frederick-vs-ja wrote:
I think we can use `TEST_HAS_BITINT` now. Ditto below.
```suggestion
# if TEST_HAS_BITINT
```
https://github.com/llvm/llvm-project/pull/196532
More information about the libcxx-commits
mailing list