Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygentype_traits.h
Go to the documentation of this file.
00001 /* 00002 * 00003 * Copyright (c) 1996,1997 00004 * Silicon Graphics Computer Systems, Inc. 00005 * 00006 * Copyright (c) 1997 00007 * Moscow Center for SPARC Technology 00008 * 00009 * Copyright (c) 1999 00010 * Boris Fomitchev 00011 * 00012 * This material is provided "as is", with absolutely no warranty expressed 00013 * or implied. Any use is at your own risk. 00014 * 00015 * Permission to use or copy this software for any purpose is hereby granted 00016 * without fee, provided the above notices are retained on all copies. 00017 * Permission to modify the code and to distribute modified code is granted, 00018 * provided the above notices are retained, and a notice that the code was 00019 * modified is included with the above copyright notice. 00020 * 00021 */ 00022 00023 #ifndef _STLP_TYPE_TRAITS_H 00024 #define _STLP_TYPE_TRAITS_H 00025 00026 /* 00027 This header file provides a framework for allowing compile time dispatch 00028 based on type attributes. This is useful when writing template code. 00029 For example, when making a copy of an array of an unknown type, it helps 00030 to know if the type has a trivial copy constructor or not, to help decide 00031 if a memcpy can be used. 00032 00033 The class template __type_traits provides a series of typedefs each of 00034 which is either __true_type or __false_type. The argument to 00035 __type_traits can be any type. The typedefs within this template will 00036 attain their correct values by one of these means: 00037 1. The general instantiation contain conservative values which work 00038 for all types. 00039 2. Specializations may be declared to make distinctions between types. 00040 3. Some compilers (such as the Silicon Graphics N32 and N64 compilers) 00041 will automatically provide the appropriate specializations for all 00042 types. 00043 00044 EXAMPLE: 00045 00046 //Copy an array of elements which have non-trivial copy constructors 00047 template <class T> void copy(T* source, T* destination, int n, __false_type); 00048 //Copy an array of elements which have trivial copy constructors. Use memcpy. 00049 template <class T> void copy(T* source, T* destination, int n, __true_type); 00050 00051 //Copy an array of any type by using the most efficient copy mechanism 00052 template <class T> inline void copy(T* source,T* destination,int n) { 00053 copy(source, destination, n, 00054 typename __type_traits<T>::has_trivial_copy_constructor()); 00055 } 00056 */ 00057 00058 #ifdef __WATCOMC__ 00059 # include <stl/_cwchar.h> 00060 #endif 00061 00062 #ifndef _STLP_TYPE_MANIPS_H 00063 # include <stl/type_manips.h> 00064 #endif 00065 00066 #ifdef _STLP_USE_BOOST_SUPPORT 00067 # include <stl/boost_type_traits.h> 00068 # include <boost/type_traits/add_reference.hpp> 00069 # include <boost/type_traits/add_const.hpp> 00070 #endif /* _STLP_USE_BOOST_SUPPORT */ 00071 00072 _STLP_BEGIN_NAMESPACE 00073 00074 #if !defined (_STLP_USE_BOOST_SUPPORT) 00075 00076 // The following could be written in terms of numeric_limits. 00077 // We're doing it separately to reduce the number of dependencies. 00078 00079 template <class _Tp> struct _IsIntegral 00080 { typedef __false_type _Ret; }; 00081 00082 # ifndef _STLP_NO_BOOL 00083 _STLP_TEMPLATE_NULL struct _IsIntegral<bool> 00084 { typedef __true_type _Ret; }; 00085 # endif /* _STLP_NO_BOOL */ 00086 00087 _STLP_TEMPLATE_NULL struct _IsIntegral<char> 00088 { typedef __true_type _Ret; }; 00089 00090 # ifndef _STLP_NO_SIGNED_BUILTINS 00091 _STLP_TEMPLATE_NULL struct _IsIntegral<signed char> 00092 { typedef __true_type _Ret; }; 00093 # endif 00094 00095 _STLP_TEMPLATE_NULL struct _IsIntegral<unsigned char> 00096 { typedef __true_type _Ret; }; 00097 00098 # if defined ( _STLP_HAS_WCHAR_T ) && ! defined (_STLP_WCHAR_T_IS_USHORT) 00099 _STLP_TEMPLATE_NULL struct _IsIntegral<wchar_t> 00100 { typedef __true_type _Ret; }; 00101 # endif /* _STLP_HAS_WCHAR_T */ 00102 00103 _STLP_TEMPLATE_NULL struct _IsIntegral<short> 00104 { typedef __true_type _Ret; }; 00105 00106 _STLP_TEMPLATE_NULL struct _IsIntegral<unsigned short> 00107 { typedef __true_type _Ret; }; 00108 00109 _STLP_TEMPLATE_NULL struct _IsIntegral<int> 00110 { typedef __true_type _Ret; }; 00111 00112 _STLP_TEMPLATE_NULL struct _IsIntegral<unsigned int> 00113 { typedef __true_type _Ret; }; 00114 00115 _STLP_TEMPLATE_NULL struct _IsIntegral<long> 00116 { typedef __true_type _Ret; }; 00117 00118 _STLP_TEMPLATE_NULL struct _IsIntegral<unsigned long> 00119 { typedef __true_type _Ret; }; 00120 00121 # ifdef _STLP_LONG_LONG 00122 _STLP_TEMPLATE_NULL struct _IsIntegral<_STLP_LONG_LONG> 00123 { typedef __true_type _Ret; }; 00124 00125 _STLP_TEMPLATE_NULL struct _IsIntegral<unsigned _STLP_LONG_LONG> 00126 { typedef __true_type _Ret; }; 00127 # endif /* _STLP_LONG_LONG */ 00128 00129 template <class _Tp> struct _IsRational 00130 { typedef __false_type _Ret; }; 00131 00132 _STLP_TEMPLATE_NULL struct _IsRational<float> 00133 { typedef __true_type _Ret; }; 00134 00135 _STLP_TEMPLATE_NULL struct _IsRational<double> 00136 { typedef __true_type _Ret; }; 00137 00138 # if !defined ( _STLP_NO_LONG_DOUBLE ) 00139 _STLP_TEMPLATE_NULL struct _IsRational<long double> 00140 { typedef __true_type _Ret; }; 00141 # endif 00142 00143 // Forward declarations. 00144 template <class _Tp> struct __type_traits; 00145 template <class _IsPOD> struct __type_traits_aux { 00146 typedef __false_type has_trivial_default_constructor; 00147 typedef __false_type has_trivial_copy_constructor; 00148 typedef __false_type has_trivial_assignment_operator; 00149 typedef __false_type has_trivial_destructor; 00150 typedef __false_type is_POD_type; 00151 }; 00152 00153 _STLP_TEMPLATE_NULL 00154 struct __type_traits_aux<__false_type> { 00155 typedef __false_type has_trivial_default_constructor; 00156 typedef __false_type has_trivial_copy_constructor; 00157 typedef __false_type has_trivial_assignment_operator; 00158 typedef __false_type has_trivial_destructor; 00159 typedef __false_type is_POD_type; 00160 }; 00161 00162 _STLP_TEMPLATE_NULL 00163 struct __type_traits_aux<__true_type> { 00164 typedef __true_type has_trivial_default_constructor; 00165 typedef __true_type has_trivial_copy_constructor; 00166 typedef __true_type has_trivial_assignment_operator; 00167 typedef __true_type has_trivial_destructor; 00168 typedef __true_type is_POD_type; 00169 }; 00170 00171 template <class _Tp> 00172 struct _IsRef { 00173 typedef __false_type _Ret; 00174 }; 00175 00176 # if defined (_STLP_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS) 00177 /* 00178 * Boris : simulation technique is used here according to Adobe Open Source License Version 1.0. 00179 * Copyright 2000 Adobe Systems Incorporated and others. All rights reserved. 00180 * Authors: Mat Marcus and Jesse Jones 00181 * The original version of this source code may be found at 00182 * http://opensource.adobe.com. 00183 */ 00184 00185 struct _PointerShim { 00186 /* 00187 * Since the compiler only allows at most one non-trivial 00188 * implicit conversion we can make use of a shim class to 00189 * be sure that IsPtr below doesn't accept classes with 00190 * implicit pointer conversion operators 00191 */ 00192 _PointerShim(const volatile void*); // no implementation 00193 }; 00194 00195 // These are the discriminating functions 00196 char _STLP_CALL _IsP(bool, _PointerShim); // no implementation is required 00197 char* _STLP_CALL _IsP(bool, ...); // no implementation is required 00198 00199 template <class _Tp> 00200 struct _IsPtr { 00201 /* 00202 * This template meta function takes a type T 00203 * and returns true exactly when T is a pointer. 00204 * One can imagine meta-functions discriminating on 00205 * other criteria. 00206 */ 00207 static _Tp& __null_rep(); 00208 enum { _Ptr = (sizeof(_IsP(false,__null_rep())) == sizeof(char)) }; 00209 typedef typename __bool2type<_Ptr>::_Ret _Ret; 00210 00211 }; 00212 00213 // we make general case dependant on the fact the type is actually a pointer. 00214 template <class _Tp> 00215 struct __type_traits : __type_traits_aux<typename _IsPtr<_Tp>::_Ret> {}; 00216 00217 # else /* _STLP_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS */ 00218 00219 template <class _Tp> struct _IsPtr { 00220 typedef __false_type _Ret; 00221 }; 00222 00223 template <class _Tp> 00224 struct __type_traits { 00225 typedef __true_type this_dummy_member_must_be_first; 00226 /* Do not remove this member. It informs a compiler which 00227 automatically specializes __type_traits that this 00228 __type_traits template is special. It just makes sure that 00229 things work if an implementation is using a template 00230 called __type_traits for something unrelated. */ 00231 00232 /* The following restrictions should be observed for the sake of 00233 compilers which automatically produce type specific specializations 00234 of this class: 00235 - You may reorder the members below if you wish 00236 - You may remove any of the members below if you wish 00237 - You must not rename members without making the corresponding 00238 name change in the compiler 00239 - Members you add will be treated like regular members unless 00240 00241 you add the appropriate support in the compiler. */ 00242 # if !defined (_STLP_HAS_TYPE_TRAITS_INTRINSICS) 00243 typedef __false_type has_trivial_default_constructor; 00244 typedef __false_type has_trivial_copy_constructor; 00245 typedef __false_type has_trivial_assignment_operator; 00246 typedef __false_type has_trivial_destructor; 00247 typedef __false_type is_POD_type; 00248 # else 00249 typedef typename __bool2type<_STLP_HAS_TRIVIAL_CONSTRUCTOR(_Tp)>::_Ret has_trivial_default_constructor; 00250 typedef typename __bool2type<_STLP_HAS_TRIVIAL_COPY(_Tp)>::_Ret has_trivial_copy_constructor; 00251 typedef typename __bool2type<_STLP_HAS_TRIVIAL_ASSIGN(_Tp)>::_Ret has_trivial_assignment_operator; 00252 typedef typename __bool2type<_STLP_HAS_TRIVIAL_DESTRUCTOR(_Tp)>::_Ret has_trivial_destructor; 00253 typedef typename __bool2type<_STLP_IS_POD(_Tp)>::_Ret is_POD_type; 00254 # endif 00255 }; 00256 00257 # if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) 00258 template <class _Tp> struct _IsPtr<_Tp*> 00259 { typedef __true_type _Ret; }; 00260 template <class _Tp> struct _IsRef<_Tp&> 00261 { typedef __true_type _Ret; }; 00262 00263 template <class _Tp> struct __type_traits<_Tp*> : __type_traits_aux<__true_type> 00264 {}; 00265 # endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */ 00266 00267 # endif /* _STLP_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS */ 00268 00269 // Provide some specializations. This is harmless for compilers that 00270 // have built-in __types_traits support, and essential for compilers 00271 // that don't. 00272 # if !defined (_STLP_QUALIFIED_SPECIALIZATION_BUG) 00273 # define _STLP_DEFINE_TYPE_TRAITS_FOR(Type) \ 00274 _STLP_TEMPLATE_NULL struct __type_traits< Type > : __type_traits_aux<__true_type> {}; \ 00275 _STLP_TEMPLATE_NULL struct __type_traits< const Type > : __type_traits_aux<__true_type> {}; \ 00276 _STLP_TEMPLATE_NULL struct __type_traits< volatile Type > : __type_traits_aux<__true_type> {}; \ 00277 _STLP_TEMPLATE_NULL struct __type_traits< const volatile Type > : __type_traits_aux<__true_type> {} 00278 # else 00279 # define _STLP_DEFINE_TYPE_TRAITS_FOR(Type) \ 00280 _STLP_TEMPLATE_NULL struct __type_traits< Type > : __type_traits_aux<__true_type> {}; 00281 # endif 00282 00283 # ifndef _STLP_NO_BOOL 00284 _STLP_DEFINE_TYPE_TRAITS_FOR(bool); 00285 # endif /* _STLP_NO_BOOL */ 00286 _STLP_DEFINE_TYPE_TRAITS_FOR(char); 00287 # ifndef _STLP_NO_SIGNED_BUILTINS 00288 _STLP_DEFINE_TYPE_TRAITS_FOR(signed char); 00289 # endif 00290 _STLP_DEFINE_TYPE_TRAITS_FOR(unsigned char); 00291 # if defined ( _STLP_HAS_WCHAR_T ) && ! defined (_STLP_WCHAR_T_IS_USHORT) 00292 _STLP_DEFINE_TYPE_TRAITS_FOR(wchar_t); 00293 # endif /* _STLP_HAS_WCHAR_T */ 00294 00295 _STLP_DEFINE_TYPE_TRAITS_FOR(short); 00296 _STLP_DEFINE_TYPE_TRAITS_FOR(unsigned short); 00297 _STLP_DEFINE_TYPE_TRAITS_FOR(int); 00298 _STLP_DEFINE_TYPE_TRAITS_FOR(unsigned int); 00299 _STLP_DEFINE_TYPE_TRAITS_FOR(long); 00300 _STLP_DEFINE_TYPE_TRAITS_FOR(unsigned long); 00301 00302 # ifdef _STLP_LONG_LONG 00303 _STLP_DEFINE_TYPE_TRAITS_FOR(_STLP_LONG_LONG); 00304 _STLP_DEFINE_TYPE_TRAITS_FOR(unsigned _STLP_LONG_LONG); 00305 # endif /* _STLP_LONG_LONG */ 00306 00307 _STLP_DEFINE_TYPE_TRAITS_FOR(float); 00308 _STLP_DEFINE_TYPE_TRAITS_FOR(double); 00309 00310 # if !defined ( _STLP_NO_LONG_DOUBLE ) 00311 _STLP_DEFINE_TYPE_TRAITS_FOR(long double); 00312 # endif 00313 00314 # if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) 00315 template <class _ArePtrs, class _Src, class _Dst> 00316 struct _IsCVConvertibleIf 00317 { typedef typename _IsCVConvertible<_Src, _Dst>::_Ret _Ret; }; 00318 00319 template <class _Src, class _Dst> 00320 struct _IsCVConvertibleIf<__false_type, _Src, _Dst> 00321 { typedef __false_type _Ret; }; 00322 # else 00323 # if defined (_STLP_MEMBER_TEMPLATE_CLASSES) 00324 template <class _ArePtrs> 00325 struct _IsCVConvertibleIfAux { 00326 template <class _Src, class _Dst> 00327 struct _In 00328 { typedef typename _IsCVConvertible<_Src, _Dst>::_Ret _Ret; }; 00329 }; 00330 00331 _STLP_TEMPLATE_NULL 00332 struct _IsCVConvertibleIfAux<__false_type> { 00333 template <class _Src, class _Dst> 00334 struct _In 00335 { typedef __false_type _Ret; }; 00336 }; 00337 00338 template <class _ArePtrs, class _Src, class _Dst> 00339 struct _IsCVConvertibleIf { 00340 typedef typename _IsCVConvertibleIfAux<_ArePtrs>::_STLP_TEMPLATE _In<_Src, _Dst>::_Ret _Ret; 00341 }; 00342 # else 00343 /* default behavior: we prefer to miss an optimization rather than taking the risk of 00344 * a compilation error if playing with types with exotic memory alignment. 00345 */ 00346 template <class _ArePtrs, class _Src, class _Dst> 00347 struct _IsCVConvertibleIf 00348 { typedef __false_type _Ret; }; 00349 # endif 00350 # endif 00351 00352 template <class _Src, class _Dst> 00353 struct _TrivialNativeTypeCopy { 00354 typedef typename _IsPtr<_Src>::_Ret _Ptr1; 00355 typedef typename _IsPtr<_Dst>::_Ret _Ptr2; 00356 typedef typename _Land2<_Ptr1, _Ptr2>::_Ret _BothPtrs; 00357 typedef typename _IsCVConvertibleIf<_BothPtrs, _Src, _Dst>::_Ret _Convertible; 00358 typedef typename _Land2<_BothPtrs, _Convertible>::_Ret _Trivial1; 00359 00360 typedef typename __bool2type<(sizeof(_Src) == sizeof(_Dst))>::_Ret _SameSize; 00361 00362 #if !defined (__BORLANDC__) || (__BORLANDC__ < 0x564) 00363 typedef typename _IsIntegral<_Src>::_Ret _Int1; 00364 #else 00365 typedef typename _UnQual<_Src>::_Type _UnQuSrc; 00366 typedef typename _IsIntegral<_UnQuSrc>::_Ret _Int1; 00367 #endif 00368 typedef typename _IsIntegral<_Dst>::_Ret _Int2; 00369 typedef typename _Land2<_Int1, _Int2>::_Ret _BothInts; 00370 00371 typedef typename _IsRational<_Src>::_Ret _Rat1; 00372 typedef typename _IsRational<_Dst>::_Ret _Rat2; 00373 typedef typename _Land2<_Rat1, _Rat2>::_Ret _BothRats; 00374 00375 typedef typename _Lor2<_BothInts, _BothRats>::_Ret _BothNatives; 00376 #if !defined (__BORLANDC__) || (__BORLANDC__ >= 0x564) 00377 typedef typename _Land2<_BothNatives, _SameSize>::_Ret _Trivial2; 00378 #else 00379 typedef typename _IsUnQual<_Dst>::_Ret _UnQualDst; 00380 typedef typename _Land3<_BothNatives, _SameSize, _UnQualDst>::_Ret _Trivial2; 00381 #endif 00382 typedef typename _Lor2<_Trivial1, _Trivial2>::_Ret _Ret; 00383 }; 00384 00385 template <class _Src, class _Dst> 00386 struct _TrivialCopy { 00387 typedef typename _TrivialNativeTypeCopy<_Src, _Dst>::_Ret _NativeRet; 00388 # if !defined (__BORLANDC__) || (__BORLANDC__ != 0x560) 00389 typedef typename __type_traits<_Src>::has_trivial_assignment_operator _Tr1; 00390 # else 00391 typedef typename _UnConstPtr<_Src*>::_Type _UnConstSrc; 00392 typedef typename __type_traits<_UnConstSrc>::has_trivial_assignment_operator _Tr1; 00393 # endif 00394 typedef typename _AreCopyable<_Src, _Dst>::_Ret _Tr2; 00395 typedef typename _Land2<_Tr1, _Tr2>::_Ret _UserRet; 00396 typedef typename _Lor2<_NativeRet, _UserRet>::_Ret _Ret; 00397 static _Ret _Answer() { return _Ret(); } 00398 }; 00399 00400 template <class _Src, class _Dst> 00401 struct _TrivialUCopy { 00402 typedef typename _TrivialNativeTypeCopy<_Src, _Dst>::_Ret _NativeRet; 00403 # if !defined (__BORLANDC__) || (__BORLANDC__ != 0x560) 00404 typedef typename __type_traits<_Src>::has_trivial_copy_constructor _Tr1; 00405 # else 00406 typedef typename _UnConstPtr<_Src*>::_Type _UnConstSrc; 00407 typedef typename __type_traits<_UnConstSrc>::has_trivial_copy_constructor _Tr1; 00408 # endif 00409 typedef typename _AreCopyable<_Src, _Dst>::_Ret _Tr2; 00410 typedef typename _Land2<_Tr1, _Tr2>::_Ret _UserRet; 00411 typedef typename _Lor2<_NativeRet, _UserRet>::_Ret _Ret; 00412 static _Ret _Answer() { return _Ret(); } 00413 }; 00414 00415 template <class _Tp> 00416 struct _DefaultZeroValue { 00417 typedef typename _IsIntegral<_Tp>::_Ret _Tr1; 00418 typedef typename _IsRational<_Tp>::_Ret _Tr2; 00419 typedef typename _IsPtr<_Tp>::_Ret _Tr3; 00420 typedef typename _Lor3<_Tr1, _Tr2, _Tr3>::_Ret _Ret; 00421 }; 00422 00423 template <class _Tp> 00424 struct _TrivialInit { 00425 # if !defined (__BORLANDC__) || (__BORLANDC__ != 0x560) 00426 typedef typename __type_traits<_Tp>::has_trivial_default_constructor _Tr1; 00427 # else 00428 typedef typename _UnConstPtr<_Tp*>::_Type _Tp1; 00429 typedef typename __type_traits<_Tp1>::has_trivial_copy_constructor _Tr1; 00430 # endif 00431 typedef typename _DefaultZeroValue<_Tp>::_Ret _Tr2; 00432 typedef typename _Not<_Tr2>::_Ret _Tr3; 00433 typedef typename _Land2<_Tr1, _Tr3>::_Ret _Ret; 00434 static _Ret _Answer() { return _Ret(); } 00435 }; 00436 00437 #endif /* !_STLP_USE_BOOST_SUPPORT */ 00438 00439 template <class _Tp> 00440 struct _IsPtrType { 00441 typedef typename _IsPtr<_Tp>::_Ret _Type; 00442 static _Type _Ret() { return _Type(); } 00443 }; 00444 00445 template <class _Tp> 00446 struct _IsRefType { 00447 typedef typename _IsRef<_Tp>::_Ret _Type; 00448 static _Type _Ret() { return _Type();} 00449 }; 00450 00451 template <class _Tp> 00452 struct __call_traits { 00453 #if defined (_STLP_USE_BOOST_SUPPORT) && !defined (_STLP_NO_EXTENSIONS) 00454 typedef typename __select< ::boost::is_reference<_Tp>::value, 00455 typename ::boost::add_const<_Tp>::type, 00456 typename ::boost::add_reference< typename ::boost::add_const<_Tp>::type >::type>::_Ret const_param_type; 00457 typedef typename __select< ::boost::is_reference<_Tp>::value, 00458 typename ::boost::remove_const<_Tp>::type, 00459 typename ::boost::add_reference<_Tp>::type>::_Ret param_type; 00460 #else 00461 typedef const _Tp& const_param_type; 00462 typedef _Tp& param_type; 00463 #endif 00464 }; 00465 00466 #if !defined (_STLP_USE_BOOST_SUPPORT) && !defined (_STLP_NO_EXTENSIONS) && defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) 00467 template <class _Tp> 00468 struct __call_traits<_Tp&> { 00469 typedef _Tp& param_type; 00470 typedef const _Tp& const_param_type; 00471 }; 00472 template <class _Tp> 00473 struct __call_traits<const _Tp&> { 00474 typedef _Tp& param_type; 00475 typedef const _Tp& const_param_type; 00476 }; 00477 #endif 00478 00479 template <class _Tp1, class _Tp2> 00480 struct _BothPtrType { 00481 typedef typename _IsPtr<_Tp1>::_Ret _IsPtr1; 00482 typedef typename _IsPtr<_Tp2>::_Ret _IsPtr2; 00483 00484 typedef typename _Land2<_IsPtr1, _IsPtr2>::_Ret _Ret; 00485 static _Ret _Answer() { return _Ret(); } 00486 }; 00487 00488 template <class _Tp1, class _Tp2, class _IsRef1, class _IsRef2> 00489 struct _OKToSwap { 00490 typedef typename _AreSameTypes<_Tp1, _Tp2>::_Ret _Same; 00491 typedef typename _Land3<_Same, _IsRef1, _IsRef2>::_Ret _Type; 00492 static _Type _Answer() { return _Type(); } 00493 }; 00494 00495 template <class _Tp1, class _Tp2, class _IsRef1, class _IsRef2> 00496 inline _OKToSwap<_Tp1, _Tp2, _IsRef1, _IsRef2> 00497 _IsOKToSwap(_Tp1*, _Tp2*, const _IsRef1&, const _IsRef2&) 00498 { return _OKToSwap<_Tp1, _Tp2, _IsRef1, _IsRef2>(); } 00499 00500 template <class _Src, class _Dst> 00501 inline _TrivialCopy<_Src, _Dst> _UseTrivialCopy(_Src*, _Dst*) 00502 { return _TrivialCopy<_Src, _Dst>(); } 00503 00504 template <class _Src, class _Dst> 00505 inline _TrivialUCopy<_Src, _Dst> _UseTrivialUCopy(_Src*, _Dst*) 00506 { return _TrivialUCopy<_Src, _Dst>(); } 00507 00508 #if defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) || defined (__BORLANDC__) || \ 00509 defined (__DMC__) 00510 struct _NegativeAnswer { 00511 typedef __false_type _Ret; 00512 static _Ret _Answer() { return _Ret(); } 00513 }; 00514 00515 template <class _Src, class _Dst> 00516 inline _NegativeAnswer _UseTrivialCopy(_Src*, const _Dst*) 00517 { return _NegativeAnswer(); } 00518 00519 template <class _Src, class _Dst> 00520 inline _NegativeAnswer _UseTrivialCopy(_Src*, volatile _Dst*) 00521 { return _NegativeAnswer(); } 00522 00523 template <class _Src, class _Dst> 00524 inline _NegativeAnswer _UseTrivialCopy(_Src*, const volatile _Dst*) 00525 { return _NegativeAnswer(); } 00526 00527 template <class _Src, class _Dst> 00528 inline _NegativeAnswer _UseTrivialUCopy(_Src*, const _Dst*) 00529 { return _NegativeAnswer(); } 00530 00531 template <class _Src, class _Dst> 00532 inline _NegativeAnswer _UseTrivialUCopy(_Src*, volatile _Dst*) 00533 { return _NegativeAnswer(); } 00534 00535 template <class _Src, class _Dst> 00536 inline _NegativeAnswer _UseTrivialUCopy(_Src*, const volatile _Dst*) 00537 { return _NegativeAnswer(); } 00538 #endif 00539 00540 template <class _Tp> 00541 inline _TrivialInit<_Tp> _UseTrivialInit(_Tp*) 00542 { return _TrivialInit<_Tp>(); } 00543 00544 template <class _Tp> 00545 struct _IsPOD { 00546 typedef typename __type_traits<_Tp>::is_POD_type _Type; 00547 static _Type _Answer() { return _Type(); } 00548 }; 00549 00550 template <class _Tp> 00551 inline _IsPOD<_Tp> _Is_POD(_Tp*) 00552 { return _IsPOD<_Tp>(); } 00553 00554 template <class _Tp> 00555 struct _DefaultZeroValueQuestion { 00556 typedef typename _DefaultZeroValue<_Tp>::_Ret _Ret; 00557 static _Ret _Answer() { return _Ret(); } 00558 }; 00559 00560 template <class _Tp> 00561 inline _DefaultZeroValueQuestion<_Tp> _HasDefaultZeroValue(_Tp*) 00562 { return _DefaultZeroValueQuestion<_Tp>(); } 00563 00564 /* 00565 * Base class used: 00566 * - to simulate partial template specialization 00567 * - to simulate partial function ordering 00568 * - to recognize STLport class from user specialized one 00569 */ 00570 template <class _Tp> 00571 struct __stlport_class 00572 { typedef _Tp _Type; }; 00573 00574 template <class _Tp> 00575 struct _IsSTLportClass { 00576 typedef typename _IsConvertible<_Tp, __stlport_class<_Tp> >::_Ret _Ret; 00577 #if defined (__BORLANDC__) 00578 enum { _Is = _IsConvertible<_Tp, __stlport_class<_Tp> >::value }; 00579 #endif 00580 }; 00581 00582 #if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) 00583 template <class _Tp> 00584 struct _SwapImplemented { 00585 typedef typename _IsSTLportClass<_Tp>::_Ret _Ret; 00586 # if defined (__BORLANDC__) 00587 enum { _Is = _IsSTLportClass<_Tp>::_Is }; 00588 # endif 00589 }; 00590 #endif 00591 00592 template <class _Tp> 00593 class _TpWithState : private _Tp { 00594 _TpWithState(); 00595 int _state; 00596 }; 00597 00598 /* This is an internal helper struct used to guess if we are working 00599 * on a stateless class. It can only be instanciated with a class type. */ 00600 template <class _Tp> 00601 struct _IsStateless { 00602 enum { _Is = sizeof(_TpWithState<_Tp>) == sizeof(int) }; 00603 typedef typename __bool2type<_Is>::_Ret _Ret; 00604 }; 00605 00606 _STLP_END_NAMESPACE 00607 00608 #ifdef _STLP_CLASS_PARTIAL_SPECIALIZATION 00609 # if defined (__BORLANDC__) || \ 00610 defined (__SUNPRO_CC) || \ 00611 (defined (__MWERKS__) && (__MWERKS__ <= 0x2303)) || \ 00612 (defined (__sgi) && defined (_COMPILER_VERSION)) || \ 00613 defined (__DMC__) 00614 # define _STLP_IS_POD_ITER(_It, _Tp) __type_traits< typename iterator_traits< _Tp >::value_type >::is_POD_type() 00615 # else 00616 # define _STLP_IS_POD_ITER(_It, _Tp) typename __type_traits< typename iterator_traits< _Tp >::value_type >::is_POD_type() 00617 # endif 00618 #else 00619 # define _STLP_IS_POD_ITER(_It, _Tp) _Is_POD( _STLP_VALUE_TYPE( _It, _Tp ) )._Answer() 00620 #endif 00621 00622 #endif /* _STLP_TYPE_TRAITS_H */ 00623 00624 // Local Variables: 00625 // mode:C++ 00626 // End: Generated on Mon May 28 2012 04:29:41 for ReactOS by
1.7.6.1
|