[libc-commits] [PATCH] D83980: [libc][NFC] Use RemoveCVType to implement IsIntegral.
Siva Chandra via Phabricator via libc-commits
libc-commits at lists.llvm.org
Thu Jul 16 12:54:32 PDT 2020
sivachandra created this revision.
sivachandra added reviewers: abrachet, lntue.
Herald added subscribers: libc-commits, ecnelises, tschuett.
Herald added a project: libc-project.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D83980
Files:
libc/utils/CPP/TypeTraits.h
Index: libc/utils/CPP/TypeTraits.h
===================================================================
--- libc/utils/CPP/TypeTraits.h
+++ libc/utils/CPP/TypeTraits.h
@@ -26,27 +26,11 @@
static constexpr bool Value = false;
};
-template <typename Type> struct IsIntegral : public FalseValue {};
-template <> struct IsIntegral<char> : public TrueValue {};
-template <> struct IsIntegral<signed char> : public TrueValue {};
-template <> struct IsIntegral<unsigned char> : public TrueValue {};
-template <> struct IsIntegral<short> : public TrueValue {};
-template <> struct IsIntegral<unsigned short> : public TrueValue {};
-template <> struct IsIntegral<int> : public TrueValue {};
-template <> struct IsIntegral<unsigned int> : public TrueValue {};
-template <> struct IsIntegral<long> : public TrueValue {};
-template <> struct IsIntegral<unsigned long> : public TrueValue {};
-template <> struct IsIntegral<long long> : public TrueValue {};
-template <> struct IsIntegral<unsigned long long> : public TrueValue {};
-template <> struct IsIntegral<bool> : public TrueValue {};
-
-template <typename T> struct IsPointerType : public FalseValue {};
-template <typename T> struct IsPointerType<T *> : public TrueValue {};
+template <typename T> struct TypeIdentity { typedef T Type; };
template <typename T1, typename T2> struct IsSame : public FalseValue {};
template <typename T> struct IsSame<T, T> : public TrueValue {};
-template <typename T> struct TypeIdentity { typedef T Type; };
template <typename T> struct RemoveCV : public TypeIdentity<T> {};
template <typename T> struct RemoveCV<const T> : public TypeIdentity<T> {};
@@ -56,6 +40,25 @@
template <typename T> using RemoveCVType = typename RemoveCV<T>::Type;
+template <typename Type> struct IsIntegral {
+ static constexpr bool Value =
+ IsSame<char, RemoveCVType<Type>>::Value ||
+ IsSame<signed char, RemoveCVType<Type>>::Value ||
+ IsSame<unsigned char, RemoveCVType<Type>>::Value ||
+ IsSame<short, RemoveCVType<Type>>::Value ||
+ IsSame<unsigned short, RemoveCVType<Type>>::Value ||
+ IsSame<int, RemoveCVType<Type>>::Value ||
+ IsSame<unsigned int, RemoveCVType<Type>>::Value ||
+ IsSame<long, RemoveCVType<Type>>::Value ||
+ IsSame<unsigned long, RemoveCVType<Type>>::Value ||
+ IsSame<long long, RemoveCVType<Type>>::Value ||
+ IsSame<unsigned long long, RemoveCVType<Type>>::Value ||
+ IsSame<bool, RemoveCVType<Type>>::Value;
+};
+
+template <typename T> struct IsPointerType : public FalseValue {};
+template <typename T> struct IsPointerType<T *> : public TrueValue {};
+
template <typename Type> struct IsFloatingPointType {
static constexpr bool Value = IsSame<float, RemoveCVType<Type>>::Value ||
IsSame<double, RemoveCVType<Type>>::Value ||
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83980.278587.patch
Type: text/x-patch
Size: 2837 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20200716/83027434/attachment.bin>
More information about the libc-commits
mailing list