[libc-commits] [libc] 6abea7a - [libc] Add missing is_unsigned in type_traits.h
via libc-commits
libc-commits at lists.llvm.org
Sun Oct 23 03:08:48 PDT 2022
Author: Guillaume Chatelet
Date: 2022-10-23T12:08:44+02:00
New Revision: 6abea7a17e9e39ef94d93d0f8fff0f736373940e
URL: https://github.com/llvm/llvm-project/commit/6abea7a17e9e39ef94d93d0f8fff0f736373940e
DIFF: https://github.com/llvm/llvm-project/commit/6abea7a17e9e39ef94d93d0f8fff0f736373940e.diff
LOG: [libc] Add missing is_unsigned in type_traits.h
Added:
Modified:
libc/src/__support/CPP/type_traits.h
Removed:
################################################################################
diff --git a/libc/src/__support/CPP/type_traits.h b/libc/src/__support/CPP/type_traits.h
index c667d0b86e6a6..0886ad2f19e17 100644
--- a/libc/src/__support/CPP/type_traits.h
+++ b/libc/src/__support/CPP/type_traits.h
@@ -105,6 +105,14 @@ template <typename T> struct is_signed {
};
template <typename T> inline constexpr bool is_signed_v = is_signed<T>::value;
+template <typename T> struct is_unsigned {
+ static constexpr bool value = is_arithmetic<T>::value && (T(-1) > T(0));
+ constexpr operator bool() const { return value; }
+ constexpr bool operator()() const { return value; }
+};
+template <typename T>
+inline constexpr bool is_unsigned_v = is_unsigned<T>::value;
+
template <typename T> struct make_unsigned;
template <> struct make_unsigned<char> { using type = unsigned char; };
template <> struct make_unsigned<signed char> { using type = unsigned char; };
More information about the libc-commits
mailing list