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

Abhinav Kumar via libc-commits libc-commits at lists.llvm.org
Sun Mar 30 22:53:59 PDT 2025


================
@@ -8,20 +8,98 @@
 #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_SIGNED_H
 #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_SIGNED_H
 
+#include "include/llvm-libc-macros/stdfix-macros.h"
 #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)))> {
   LIBC_INLINE constexpr operator bool() const { return is_signed::value; }
   LIBC_INLINE constexpr bool operator()() const { return is_signed::value; }
 };
----------------
kr-2003 wrote:

> So it looks like `static_assert` with that works fine, but not with `EXPECT_EQ` in the tests that you added. Probably something is missing for fixed point support in constexpr context.

opened issue at #133680

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


More information about the libc-commits mailing list