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