type_traits.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef _EXT_TYPE_TRAITS
00036 #define _EXT_TYPE_TRAITS 1
00037
00038 #pragma GCC system_header
00039
00040 #include <bits/c++config.h>
00041 #include <bits/cpp_type_traits.h>
00042
00043 _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
00044
00045
00046 template<bool, typename>
00047 struct __enable_if
00048 { };
00049
00050 template<typename _Tp>
00051 struct __enable_if<true, _Tp>
00052 { typedef _Tp __type; };
00053
00054
00055
00056 template<bool _Cond, typename _Iftrue, typename _Iffalse>
00057 struct __conditional_type
00058 { typedef _Iftrue __type; };
00059
00060 template<typename _Iftrue, typename _Iffalse>
00061 struct __conditional_type<false, _Iftrue, _Iffalse>
00062 { typedef _Iffalse __type; };
00063
00064
00065
00066 template<typename _Tp>
00067 struct __add_unsigned
00068 {
00069 private:
00070 typedef __enable_if<std::__is_integer<_Tp>::__value, _Tp> __if_type;
00071
00072 public:
00073 typedef typename __if_type::__type __type;
00074 };
00075
00076 template<>
00077 struct __add_unsigned<char>
00078 { typedef unsigned char __type; };
00079
00080 template<>
00081 struct __add_unsigned<signed char>
00082 { typedef unsigned char __type; };
00083
00084 template<>
00085 struct __add_unsigned<short>
00086 { typedef unsigned short __type; };
00087
00088 template<>
00089 struct __add_unsigned<int>
00090 { typedef unsigned int __type; };
00091
00092 template<>
00093 struct __add_unsigned<long>
00094 { typedef unsigned long __type; };
00095
00096 template<>
00097 struct __add_unsigned<long long>
00098 { typedef unsigned long long __type; };
00099
00100
00101 template<>
00102 struct __add_unsigned<bool>;
00103
00104 template<>
00105 struct __add_unsigned<wchar_t>;
00106
00107
00108
00109 template<typename _Tp>
00110 struct __remove_unsigned
00111 {
00112 private:
00113 typedef __enable_if<std::__is_integer<_Tp>::__value, _Tp> __if_type;
00114
00115 public:
00116 typedef typename __if_type::__type __type;
00117 };
00118
00119 template<>
00120 struct __remove_unsigned<char>
00121 { typedef signed char __type; };
00122
00123 template<>
00124 struct __remove_unsigned<unsigned char>
00125 { typedef signed char __type; };
00126
00127 template<>
00128 struct __remove_unsigned<unsigned short>
00129 { typedef short __type; };
00130
00131 template<>
00132 struct __remove_unsigned<unsigned int>
00133 { typedef int __type; };
00134
00135 template<>
00136 struct __remove_unsigned<unsigned long>
00137 { typedef long __type; };
00138
00139 template<>
00140 struct __remove_unsigned<unsigned long long>
00141 { typedef long long __type; };
00142
00143
00144 template<>
00145 struct __remove_unsigned<bool>;
00146
00147 template<>
00148 struct __remove_unsigned<wchar_t>;
00149
00150
00151
00152 template<typename _Type>
00153 inline bool
00154 __is_null_pointer(_Type* __ptr)
00155 { return __ptr == 0; }
00156
00157 template<typename _Type>
00158 inline bool
00159 __is_null_pointer(_Type)
00160 { return false; }
00161
00162
00163
00164 template<typename _Tp, bool = std::__is_integer<_Tp>::__value>
00165 struct __promote
00166 { typedef double __type; };
00167
00168 template<typename _Tp>
00169 struct __promote<_Tp, false>
00170 { typedef _Tp __type; };
00171
00172 template<typename _Tp, typename _Up>
00173 struct __promote_2
00174 {
00175 private:
00176 typedef typename __promote<_Tp>::__type __type1;
00177 typedef typename __promote<_Up>::__type __type2;
00178
00179 public:
00180 typedef __typeof__(__type1() + __type2()) __type;
00181 };
00182
00183 template<typename _Tp, typename _Up, typename _Vp>
00184 struct __promote_3
00185 {
00186 private:
00187 typedef typename __promote<_Tp>::__type __type1;
00188 typedef typename __promote<_Up>::__type __type2;
00189 typedef typename __promote<_Vp>::__type __type3;
00190
00191 public:
00192 typedef __typeof__(__type1() + __type2() + __type3()) __type;
00193 };
00194
00195 template<typename _Tp, typename _Up, typename _Vp, typename _Wp>
00196 struct __promote_4
00197 {
00198 private:
00199 typedef typename __promote<_Tp>::__type __type1;
00200 typedef typename __promote<_Up>::__type __type2;
00201 typedef typename __promote<_Vp>::__type __type3;
00202 typedef typename __promote<_Wp>::__type __type4;
00203
00204 public:
00205 typedef __typeof__(__type1() + __type2() + __type3() + __type4()) __type;
00206 };
00207
00208 _GLIBCXX_END_NAMESPACE
00209
00210 #endif