88#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_UNSIGNED_H
99#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_UNSIGNED_H
1010
11+ #include " include/llvm-libc-macros/stdfix-macros.h"
1112#include " src/__support/CPP/type_traits/bool_constant.h"
1213#include " src/__support/CPP/type_traits/is_arithmetic.h"
1314#include " src/__support/CPP/type_traits/is_fixed_point.h"
@@ -19,64 +20,42 @@ namespace cpp {
1920
2021// Primary template: handles arithmetic and signed fixed-point types
2122template <typename T>
22- struct is_unsigned
23- : bool_constant<((is_fixed_point_v<T> || is_arithmetic_v<T>) &&
24- (T(-1 ) > T (0 )))> {
23+ struct is_unsigned : bool_constant<(is_arithmetic_v<T> && (T(-1 ) > T (0 )))> {
2524 LIBC_INLINE constexpr operator bool () const { return is_unsigned::value; }
2625 LIBC_INLINE constexpr bool operator ()() const { return is_unsigned::value; }
2726};
2827
2928#ifdef LIBC_COMPILER_HAS_FIXED_POINT
3029// Specializations for unsigned fixed-point types
31- template <> struct is_unsigned <unsigned short _Fract> : bool_constant<true > {
32- LIBC_INLINE constexpr operator bool () const { return is_unsigned::value; }
33- LIBC_INLINE constexpr bool operator ()() const { return is_unsigned::value; }
34- };
35- template <> struct is_unsigned <unsigned _Fract> : bool_constant<true > {
36- LIBC_INLINE constexpr operator bool () const { return is_unsigned::value; }
37- LIBC_INLINE constexpr bool operator ()() const { return is_unsigned::value; }
38- };
39- template <> struct is_unsigned <unsigned long _Fract> : bool_constant<true > {
40- LIBC_INLINE constexpr operator bool () const { return is_unsigned::value; }
41- LIBC_INLINE constexpr bool operator ()() const { return is_unsigned::value; }
42- };
43- template <> struct is_unsigned <unsigned short accum> : bool_constant<true > {
44- LIBC_INLINE constexpr operator bool () const { return is_unsigned::value; }
45- LIBC_INLINE constexpr bool operator ()() const { return is_unsigned::value; }
46- };
47- template <> struct is_unsigned <unsigned accum> : bool_constant<true > {
48- LIBC_INLINE constexpr operator bool () const { return is_unsigned::value; }
49- LIBC_INLINE constexpr bool operator ()() const { return is_unsigned::value; }
50- };
51- template <> struct is_unsigned <unsigned long accum> : bool_constant<true > {
52- LIBC_INLINE constexpr operator bool () const { return is_unsigned::value; }
53- LIBC_INLINE constexpr bool operator ()() const { return is_unsigned::value; }
54- };
55- template <>
56- struct is_unsigned <unsigned short sat _Fract> : bool_constant<true > {
57- LIBC_INLINE constexpr operator bool () const { return is_unsigned::value; }
58- LIBC_INLINE constexpr bool operator ()() const { return is_unsigned::value; }
59- };
60- template <> struct is_unsigned <unsigned sat _Fract> : bool_constant<true > {
61- LIBC_INLINE constexpr operator bool () const { return is_unsigned::value; }
62- LIBC_INLINE constexpr bool operator ()() const { return is_unsigned::value; }
63- };
64- template <> struct is_unsigned <unsigned long sat _Fract> : bool_constant<true > {
65- LIBC_INLINE constexpr operator bool () const { return is_unsigned::value; }
66- LIBC_INLINE constexpr bool operator ()() const { return is_unsigned::value; }
67- };
68- template <> struct is_unsigned <unsigned short sat accum> : bool_constant<true > {
69- LIBC_INLINE constexpr operator bool () const { return is_unsigned::value; }
70- LIBC_INLINE constexpr bool operator ()() const { return is_unsigned::value; }
71- };
72- template <> struct is_unsigned <unsigned sat accum> : bool_constant<true > {
73- LIBC_INLINE constexpr operator bool () const { return is_unsigned::value; }
74- LIBC_INLINE constexpr bool operator ()() const { return is_unsigned::value; }
75- };
76- template <> struct is_unsigned <unsigned long sat accum> : bool_constant<true > {
77- LIBC_INLINE constexpr operator bool () const { return is_unsigned::value; }
78- LIBC_INLINE constexpr bool operator ()() const { return is_unsigned::value; }
30+ template <typename T, bool IsUnsigned>
31+ struct fixed_point_is_unsigned : bool_constant<IsUnsigned> {
32+ LIBC_INLINE constexpr operator bool () const { return fixed_point_is_unsigned::value; }
33+ LIBC_INLINE constexpr bool operator ()() const { return fixed_point_is_unsigned::value; }
7934};
35+ template <> struct is_unsigned <fract> : fixed_point_is_unsigned<fract, false > {};
36+ template <> struct is_unsigned <unsigned short fract> : fixed_point_is_unsigned<unsigned short fract, true > {};
37+ template <> struct is_unsigned <unsigned fract> : fixed_point_is_unsigned<unsigned fract, true > {};
38+ template <> struct is_unsigned <unsigned long fract> : fixed_point_is_unsigned<unsigned long fract, true > {};
39+ template <> struct is_unsigned <short fract> : fixed_point_is_unsigned<short fract, false > {};
40+ template <> struct is_unsigned <long fract> : fixed_point_is_unsigned<long fract, false > {};
41+ template <> struct is_unsigned <accum> : fixed_point_is_unsigned<accum, false > {};
42+ template <> struct is_unsigned <unsigned short accum> : fixed_point_is_unsigned<unsigned short accum, true > {};
43+ template <> struct is_unsigned <unsigned accum> : fixed_point_is_unsigned<unsigned accum, true > {};
44+ template <> struct is_unsigned <unsigned long accum> : fixed_point_is_unsigned<unsigned long accum, true > {};
45+ template <> struct is_unsigned <short accum> : fixed_point_is_unsigned<short accum, false > {};
46+ template <> struct is_unsigned <long accum> : fixed_point_is_unsigned<long accum, false > {};
47+ template <> struct is_unsigned <sat fract> : fixed_point_is_unsigned<sat fract, false > {};
48+ template <> struct is_unsigned <unsigned short sat fract> : fixed_point_is_unsigned<unsigned short sat fract, true > {};
49+ template <> struct is_unsigned <unsigned sat fract> : fixed_point_is_unsigned<unsigned sat fract, true > {};
50+ template <> struct is_unsigned <unsigned long sat fract> : fixed_point_is_unsigned<unsigned long sat fract, true > {};
51+ template <> struct is_unsigned <short sat fract> : fixed_point_is_unsigned<short sat fract, false > {};
52+ template <> struct is_unsigned <long sat fract> : fixed_point_is_unsigned<long sat fract, false > {};
53+ template <> struct is_unsigned <sat accum> : fixed_point_is_unsigned<sat accum, false > {};
54+ template <> struct is_unsigned <unsigned short sat accum> : fixed_point_is_unsigned<unsigned short sat accum, true > {};
55+ template <> struct is_unsigned <unsigned sat accum> : fixed_point_is_unsigned<unsigned sat accum, true > {};
56+ template <> struct is_unsigned <unsigned long sat accum> : fixed_point_is_unsigned<unsigned long sat accum, true > {};
57+ template <> struct is_unsigned <short sat accum> : fixed_point_is_unsigned<short sat accum, false > {};
58+ template <> struct is_unsigned <long sat accum> : fixed_point_is_unsigned<long sat accum, false > {};
8059#endif // LIBC_COMPILER_HAS_FIXED_POINT
8160
8261template <typename T>
0 commit comments