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