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
00107
00108 template<class _Sp, class _Tp>
00109 struct __traitor
00110 {
00111 enum { __value = bool(_Sp::__value) || bool(_Tp::__value) };
00112 typedef typename __truth_type<__value>::__type __type;
00113 };
00114
00115
00116 template<typename, typename>
00117 struct __are_same
00118 {
00119 enum { __value = 0 };
00120 typedef __false_type __type;
00121 };
00122
00123 template<typename _Tp>
00124 struct __are_same<_Tp, _Tp>
00125 {
00126 enum { __value = 1 };
00127 typedef __true_type __type;
00128 };
00129
00130
00131 template<typename, bool>
00132 struct __enable_if
00133 {
00134 };
00135
00136 template<typename _Tp>
00137 struct __enable_if<_Tp, true>
00138 {
00139 typedef _Tp __type;
00140 };
00141
00142
00143 template<typename _Tp>
00144 struct __is_void
00145 {
00146 enum { __value = 0 };
00147 typedef __false_type __type;
00148 };
00149
00150 template<>
00151 struct __is_void<void>
00152 {
00153 enum { __value = 1 };
00154 typedef __true_type __type;
00155 };
00156
00157
00158
00159
00160 template<typename _Tp>
00161 struct __is_integer
00162 {
00163 enum { __value = 0 };
00164 typedef __false_type __type;
00165 };
00166
00167
00168
00169
00170 template<>
00171 struct __is_integer<bool>
00172 {
00173 enum { __value = 1 };
00174 typedef __true_type __type;
00175 };
00176
00177 template<>
00178 struct __is_integer<char>
00179 {
00180 enum { __value = 1 };
00181 typedef __true_type __type;
00182 };
00183
00184 template<>
00185 struct __is_integer<signed char>
00186 {
00187 enum { __value = 1 };
00188 typedef __true_type __type;
00189 };
00190
00191 template<>
00192 struct __is_integer<unsigned char>
00193 {
00194 enum { __value = 1 };
00195 typedef __true_type __type;
00196 };
00197
00198 # ifdef _GLIBCXX_USE_WCHAR_T
00199 template<>
00200 struct __is_integer<wchar_t>
00201 {
00202 enum { __value = 1 };
00203 typedef __true_type __type;
00204 };
00205 # endif
00206
00207 template<>
00208 struct __is_integer<short>
00209 {
00210 enum { __value = 1 };
00211 typedef __true_type __type;
00212 };
00213
00214 template<>
00215 struct __is_integer<unsigned short>
00216 {
00217 enum { __value = 1 };
00218 typedef __true_type __type;
00219 };
00220
00221 template<>
00222 struct __is_integer<int>
00223 {
00224 enum { __value = 1 };
00225 typedef __true_type __type;
00226 };
00227
00228 template<>
00229 struct __is_integer<unsigned int>
00230 {
00231 enum { __value = 1 };
00232 typedef __true_type __type;
00233 };
00234
00235 template<>
00236 struct __is_integer<long>
00237 {
00238 enum { __value = 1 };
00239 typedef __true_type __type;
00240 };
00241
00242 template<>
00243 struct __is_integer<unsigned long>
00244 {
00245 enum { __value = 1 };
00246 typedef __true_type __type;
00247 };
00248
00249 template<>
00250 struct __is_integer<long long>
00251 {
00252 enum { __value = 1 };
00253 typedef __true_type __type;
00254 };
00255
00256 template<>
00257 struct __is_integer<unsigned long long>
00258 {
00259 enum { __value = 1 };
00260 typedef __true_type __type;
00261 };
00262
00263
00264
00265
00266 template<typename _Tp>
00267 struct __is_floating
00268 {
00269 enum { __value = 0 };
00270 typedef __false_type __type;
00271 };
00272
00273
00274 template<>
00275 struct __is_floating<float>
00276 {
00277 enum { __value = 1 };
00278 typedef __true_type __type;
00279 };
00280
00281 template<>
00282 struct __is_floating<double>
00283 {
00284 enum { __value = 1 };
00285 typedef __true_type __type;
00286 };
00287
00288 template<>
00289 struct __is_floating<long double>
00290 {
00291 enum { __value = 1 };
00292 typedef __true_type __type;
00293 };
00294
00295
00296
00297
00298 template<typename _Tp>
00299 struct __is_pointer
00300 {
00301 enum { __value = 0 };
00302 typedef __false_type __type;
00303 };
00304
00305 template<typename _Tp>
00306 struct __is_pointer<_Tp*>
00307 {
00308 enum { __value = 1 };
00309 typedef __true_type __type;
00310 };
00311
00312
00313
00314
00315 template<typename _Tp>
00316 struct __is_normal_iterator
00317 {
00318 enum { __value = 0 };
00319 typedef __false_type __type;
00320 };
00321
00322 template<typename _Iterator, typename _Container>
00323 struct __is_normal_iterator< __gnu_cxx::__normal_iterator<_Iterator,
00324 _Container> >
00325 {
00326 enum { __value = 1 };
00327 typedef __true_type __type;
00328 };
00329
00330
00331
00332
00333 template<typename _Tp>
00334 struct __is_arithmetic
00335 : public __traitor<__is_integer<_Tp>, __is_floating<_Tp> >
00336 { };
00337
00338
00339
00340
00341 template<typename _Tp>
00342 struct __is_fundamental
00343 : public __traitor<__is_void<_Tp>, __is_arithmetic<_Tp> >
00344 { };
00345
00346
00347
00348
00349 template<typename _Tp>
00350 struct __is_scalar
00351 : public __traitor<__is_arithmetic<_Tp>, __is_pointer<_Tp> >
00352 { };
00353
00354
00355
00356
00357 template<typename _Tp>
00358 struct __is_pod
00359 {
00360 enum
00361 {
00362 __value = (sizeof(__gnu_internal::__test_type<_Tp>(0))
00363 != sizeof(__gnu_internal::__one))
00364 };
00365 };
00366
00367
00368
00369
00370 template<typename _Tp>
00371 struct __is_empty
00372 {
00373 private:
00374 template<typename>
00375 struct __first { };
00376 template<typename _Up>
00377 struct __second
00378 : public _Up { };
00379
00380 public:
00381 enum
00382 {
00383 __value = sizeof(__first<_Tp>) == sizeof(__second<_Tp>)
00384 };
00385 };
00386
00387 }
00388
00389 #endif //_CPP_TYPE_TRAITS_H