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