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
00036
00037
00038 #ifndef _CPP_TYPE_TRAITS_H
00039 #define _CPP_TYPE_TRAITS_H 1
00040
00041 #pragma GCC system_header
00042
00043 #include <bits/c++config.h>
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075 namespace __gnu_internal
00076 {
00077 typedef char __one;
00078 typedef char __two[2];
00079
00080 template<typename _Tp>
00081 __one __test_type(int _Tp::*);
00082 template<typename _Tp>
00083 __two& __test_type(...);
00084 }
00085
00086
00087 namespace __gnu_cxx
00088 {
00089 template<typename _Iterator, typename _Container>
00090 class __normal_iterator;
00091 }
00092
00093 struct __true_type { };
00094 struct __false_type { };
00095
00096 namespace std
00097 {
00098 template<bool>
00099 struct __truth_type
00100 { typedef __false_type __type; };
00101
00102 template<>
00103 struct __truth_type<true>
00104 { typedef __true_type __type; };
00105
00106 template<class _Sp, class _Tp>
00107 struct __traitor
00108 {
00109 enum { __value = _Sp::__value || _Tp::__value };
00110 typedef typename __truth_type<__value>::__type __type;
00111 };
00112
00113
00114 template<typename, typename>
00115 struct __are_same
00116 {
00117 enum { __value = 0 };
00118 typedef __false_type __type;
00119 };
00120
00121 template<typename _Tp>
00122 struct __are_same<_Tp, _Tp>
00123 {
00124 enum { __value = 1 };
00125 typedef __true_type __type;
00126 };
00127
00128
00129 template<typename, bool>
00130 struct __enable_if
00131 {
00132 };
00133
00134 template<typename _Tp>
00135 struct __enable_if<_Tp, true>
00136 {
00137 typedef _Tp __type;
00138 };
00139
00140
00141 template<typename _Tp>
00142 struct __is_void
00143 {
00144 enum { __value = 0 };
00145 typedef __false_type __type;
00146 };
00147
00148 template<>
00149 struct __is_void<void>
00150 {
00151 enum { __value = 1 };
00152 typedef __true_type __type;
00153 };
00154
00155
00156
00157
00158 template<typename _Tp>
00159 struct __is_integer
00160 {
00161 enum { __value = 0 };
00162 typedef __false_type __type;
00163 };
00164
00165
00166
00167
00168 template<>
00169 struct __is_integer<bool>
00170 {
00171 enum { __value = 1 };
00172 typedef __true_type __type;
00173 };
00174
00175 template<>
00176 struct __is_integer<char>
00177 {
00178 enum { __value = 1 };
00179 typedef __true_type __type;
00180 };
00181
00182 template<>
00183 struct __is_integer<signed char>
00184 {
00185 enum { __value = 1 };
00186 typedef __true_type __type;
00187 };
00188
00189 template<>
00190 struct __is_integer<unsigned char>
00191 {
00192 enum { __value = 1 };
00193 typedef __true_type __type;
00194 };
00195
00196 # ifdef _GLIBCXX_USE_WCHAR_T
00197 template<>
00198 struct __is_integer<wchar_t>
00199 {
00200 enum { __value = 1 };
00201 typedef __true_type __type;
00202 };
00203 # endif
00204
00205 template<>
00206 struct __is_integer<short>
00207 {
00208 enum { __value = 1 };
00209 typedef __true_type __type;
00210 };
00211
00212 template<>
00213 struct __is_integer<unsigned short>
00214 {
00215 enum { __value = 1 };
00216 typedef __true_type __type;
00217 };
00218
00219 template<>
00220 struct __is_integer<int>
00221 {
00222 enum { __value = 1 };
00223 typedef __true_type __type;
00224 };
00225
00226 template<>
00227 struct __is_integer<unsigned int>
00228 {
00229 enum { __value = 1 };
00230 typedef __true_type __type;
00231 };
00232
00233 template<>
00234 struct __is_integer<long>
00235 {
00236 enum { __value = 1 };
00237 typedef __true_type __type;
00238 };
00239
00240 template<>
00241 struct __is_integer<unsigned long>
00242 {
00243 enum { __value = 1 };
00244 typedef __true_type __type;
00245 };
00246
00247 template<>
00248 struct __is_integer<long long>
00249 {
00250 enum { __value = 1 };
00251 typedef __true_type __type;
00252 };
00253
00254 template<>
00255 struct __is_integer<unsigned long long>
00256 {
00257 enum { __value = 1 };
00258 typedef __true_type __type;
00259 };
00260
00261
00262
00263
00264 template<typename _Tp>
00265 struct __is_floating
00266 {
00267 enum { __value = 0 };
00268 typedef __false_type __type;
00269 };
00270
00271
00272 template<>
00273 struct __is_floating<float>
00274 {
00275 enum { __value = 1 };
00276 typedef __true_type __type;
00277 };
00278
00279 template<>
00280 struct __is_floating<double>
00281 {
00282 enum { __value = 1 };
00283 typedef __true_type __type;
00284 };
00285
00286 template<>
00287 struct __is_floating<long double>
00288 {
00289 enum { __value = 1 };
00290 typedef __true_type __type;
00291 };
00292
00293
00294
00295
00296 template<typename _Tp>
00297 struct __is_pointer
00298 {
00299 enum { __value = 0 };
00300 typedef __false_type __type;
00301 };
00302
00303 template<typename _Tp>
00304 struct __is_pointer<_Tp*>
00305 {
00306 enum { __value = 1 };
00307 typedef __true_type __type;
00308 };
00309
00310
00311
00312
00313 template<typename _Tp>
00314 struct __is_normal_iterator
00315 {
00316 enum { __value = 0 };
00317 typedef __false_type __type;
00318 };
00319
00320 template<typename _Iterator, typename _Container>
00321 struct __is_normal_iterator< __gnu_cxx::__normal_iterator<_Iterator,
00322 _Container> >
00323 {
00324 enum { __value = 1 };
00325 typedef __true_type __type;
00326 };
00327
00328
00329
00330
00331 template<typename _Tp>
00332 struct __is_arithmetic
00333 : public __traitor<__is_integer<_Tp>, __is_floating<_Tp> >
00334 { };
00335
00336
00337
00338
00339 template<typename _Tp>
00340 struct __is_fundamental
00341 : public __traitor<__is_void<_Tp>, __is_arithmetic<_Tp> >
00342 { };
00343
00344
00345
00346
00347 template<typename _Tp>
00348 struct __is_scalar
00349 : public __traitor<__is_arithmetic<_Tp>, __is_pointer<_Tp> >
00350 { };
00351
00352
00353
00354
00355 template<typename _Tp>
00356 struct __is_pod
00357 {
00358 enum
00359 {
00360 __value = (sizeof(__gnu_internal::__test_type<_Tp>(0))
00361 != sizeof(__gnu_internal::__one))
00362 };
00363 };
00364
00365 }
00366
00367 #endif //_CPP_TYPE_TRAITS_H