00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef LLVM_SUPPORT_TYPE_TRAITS_H
00018 #define LLVM_SUPPORT_TYPE_TRAITS_H
00019
00020 #include <utility>
00021
00022
00023
00024
00025
00026
00027 namespace llvm {
00028
00029 namespace dont_use
00030 {
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 template<typename T> char is_class_helper(void(T::*)());
00041 template<typename T> double is_class_helper(...);
00042 }
00043
00044 template <typename T>
00045 struct is_class
00046 {
00047
00048
00049
00050 public:
00051 enum { value = sizeof(char) == sizeof(dont_use::is_class_helper<T>(0)) };
00052 };
00053
00054
00057 template <typename T>
00058 struct isPodLike {
00059
00060
00061 static const bool value = !is_class<T>::value;
00062 };
00063
00064
00065 template<typename T, typename U>
00066 struct isPodLike<std::pair<T, U> > {
00067 static const bool value = isPodLike<T>::value & isPodLike<U>::value;
00068 };
00069
00070
00073 template<typename T, typename U>
00074 struct is_same {
00075 static const bool value = false;
00076 };
00077
00078 template<typename T>
00079 struct is_same<T, T> {
00080 static const bool value = true;
00081 };
00082
00083
00084 template<bool Cond, typename T = void>
00085 struct enable_if_c {
00086 typedef T type;
00087 };
00088
00089 template<typename T> struct enable_if_c<false, T> { };
00090
00091
00092 template<typename Cond, typename T = void>
00093 struct enable_if : public enable_if_c<Cond::value, T> { };
00094
00095 namespace dont_use {
00096 template<typename Base> char base_of_helper(const volatile Base*);
00097 template<typename Base> double base_of_helper(...);
00098 }
00099
00102 template<typename Base, typename Derived>
00103 struct is_base_of {
00104 static const bool value
00105 = is_class<Base>::value && is_class<Derived>::value &&
00106 sizeof(char) == sizeof(dont_use::base_of_helper<Base>((Derived*)0));
00107 };
00108
00109
00110
00111 template <typename T> struct remove_pointer { typedef T type; };
00112 template <typename T> struct remove_pointer<T*> { typedef T type; };
00113 template <typename T> struct remove_pointer<T*const> { typedef T type; };
00114 template <typename T> struct remove_pointer<T*volatile> { typedef T type; };
00115 template <typename T> struct remove_pointer<T*const volatile> {
00116 typedef T type; };
00117
00118 template <bool, typename T, typename F>
00119 struct conditional { typedef T type; };
00120
00121 template <typename T, typename F>
00122 struct conditional<false, T, F> { typedef F type; };
00123
00124 }
00125
00126 #endif