[libc-commits] [libc] [libc] Added support for fixed-points in ``is_signed`` and ``is_unsigned``. (PR #133371)

via libc-commits libc-commits at lists.llvm.org
Fri Mar 28 04:50:56 PDT 2025


================
@@ -10,18 +10,73 @@
 
 #include "src/__support/CPP/type_traits/bool_constant.h"
 #include "src/__support/CPP/type_traits/is_arithmetic.h"
+#include "src/__support/CPP/type_traits/is_fixed_point.h"
 #include "src/__support/macros/attributes.h"
 #include "src/__support/macros/config.h"
 
 namespace LIBC_NAMESPACE_DECL {
 namespace cpp {
 
-// is_signed
+// Primary template: handles arithmetic and signed fixed-point types
 template <typename T>
-struct is_signed : bool_constant<(is_arithmetic_v<T> && (T(-1) < T(0)))> {
+struct is_signed : bool_constant<((is_fixed_point_v<T> || is_arithmetic_v<T>) &&
----------------
lntue wrote:

probably you could change it to:
```
(is_fixed_point_v<T> && T(-0.5) < T(0)) || (is_arithmetic_v<T> && T(-1) < T(0))
```
and remove all the fixed point specializations.

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


More information about the libc-commits mailing list