/home/ntakagi/work/STLport-5.1.5/stlport/stl/type_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   typedef typename _IsIntegral<_Src>::_Ret _Int1;
00363   typedef typename _IsIntegral<_Dst>::_Ret _Int2;
00364   typedef typename _Land2<_Int1, _Int2>::_Ret _BothInts;
00365 
00366   typedef typename _IsRational<_Src>::_Ret _Rat1;
00367   typedef typename _IsRational<_Dst>::_Ret _Rat2;
00368   typedef typename _Land2<_Rat1, _Rat2>::_Ret _BothRats;
00369 
00370   typedef typename _Lor2<_BothInts, _BothRats>::_Ret _BothNatives;
00371   typedef typename _Land2<_BothNatives, _SameSize>::_Ret _Trivial2;
00372 
00373   typedef typename _Lor2<_Trivial1, _Trivial2>::_Ret _Ret;
00374 };
00375 
00376 template <class _Src, class _Dst>
00377 struct _TrivialCopy {
00378   typedef typename _TrivialNativeTypeCopy<_Src, _Dst>::_Ret _NativeRet;
00379 
00380 #if !defined (__BORLANDC__) || (__BORLANDC__ != 0x560)
00381   typedef typename __type_traits<_Src>::has_trivial_assignment_operator _Tr1;
00382 #else
00383   typedef typename _UnConstPtr<_Src*>::_Type _Tp3;
00384   typedef typename __type_traits<_Tp3>::has_trivial_assignment_operator _Tr1;
00385 #endif
00386   typedef typename _AreSameUnCVTypes<_Src, _Dst>::_Ret _Tr2;
00387   typedef typename _Land2<_Tr1, _Tr2>::_Ret _UserRet;
00388 
00389   typedef typename _Lor2<_NativeRet, _UserRet>::_Ret _Ret;
00390   static _Ret _Answer() { return _Ret(); }
00391 };
00392 
00393 template <class _Src, class _Dst>
00394 struct _TrivialUCopy {
00395   typedef typename _TrivialNativeTypeCopy<_Src, _Dst>::_Ret _NativeRet;
00396 
00397 #if !defined (__BORLANDC__) || (__BORLANDC__ != 0x560)
00398   typedef typename __type_traits<_Src>::has_trivial_copy_constructor _Tr1;
00399 #else
00400   typedef typename _UnConstPtr<_Src*>::_Type _Tp3;
00401   typedef typename __type_traits<_Tp3>::has_trivial_copy_constructor _Tr1;
00402 #endif
00403   typedef typename _AreSameUnCVTypes<_Src, _Dst>::_Ret _Tr2;
00404   typedef typename _Land2<_Tr1, _Tr2>::_Ret _UserRet;
00405 
00406   typedef typename _Lor2<_NativeRet, _UserRet>::_Ret _Ret;
00407   static _Ret _Answer() { return _Ret(); }
00408 };
00409 
00410 template <class _Tp>
00411 struct _DefaultZeroValue {
00412   typedef typename _IsIntegral<_Tp>::_Ret _Tr1;
00413   typedef typename _IsRational<_Tp>::_Ret _Tr2;
00414   typedef typename _IsPtr<_Tp>::_Ret _Tr3;
00415   typedef typename _Lor3<_Tr1, _Tr2, _Tr3>::_Ret _Ret;
00416 };
00417 
00418 template <class _Tp>
00419 struct _TrivialInit {
00420 #if !defined (__BORLANDC__) || (__BORLANDC__ != 0x560)
00421   typedef typename __type_traits<_Tp>::has_trivial_default_constructor _Tr1;
00422 #else
00423   typedef typename _UnConstPtr<_Tp*>::_Type _Tp1;
00424   typedef typename __type_traits<_Tp1>::has_trivial_copy_constructor _Tr1;
00425 #endif
00426   typedef typename _DefaultZeroValue<_Tp>::_Ret _Tr2;
00427   typedef typename _Not<_Tr2>::_Ret _Tr3;
00428   typedef typename _Land2<_Tr1, _Tr3>::_Ret _Ret;
00429   static _Ret _Answer() { return _Ret(); }
00430 };
00431 
00432 #endif /* !_STLP_USE_BOOST_SUPPORT */
00433 
00434 template <class _Tp>
00435 struct _IsPtrType {
00436   typedef typename _IsPtr<_Tp>::_Ret _Type;
00437   static _Type _Ret() { return _Type(); }
00438 };
00439 
00440 template <class _Tp>
00441 struct _IsRefType {
00442   typedef typename _IsRef<_Tp>::_Ret _Type;
00443   static _Type _Ret() { return _Type();}
00444 };
00445 
00446 template <class _Tp>
00447 struct __call_traits {
00448 #if defined (_STLP_USE_BOOST_SUPPORT) && !defined (_STLP_NO_EXTENSIONS)
00449   typedef typename __select< ::boost::is_reference<_Tp>::value,
00450                              _Tp, typename ::boost::add_reference< typename ::boost::add_const<_Tp>::type >::type>::_Ret param_type;
00451 #else
00452   typedef const _Tp& param_type;
00453 #endif /* _STLP_USE_BOOST_SUPPORT */
00454 };
00455 
00456 #if !defined (_STLP_USE_BOOST_SUPPORT) && !defined (_STLP_NO_EXTENSIONS) && defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
00457 template <class _Tp>
00458 struct __call_traits<_Tp&>
00459 { typedef _Tp& param_type; };
00460 #endif
00461 
00462 template <class _Tp1, class _Tp2>
00463 struct _BothPtrType {
00464   typedef typename _IsPtr<_Tp1>::_Ret _IsPtr1;
00465   typedef typename _IsPtr<_Tp2>::_Ret _IsPtr2;
00466 
00467   typedef typename _Land2<_IsPtr1, _IsPtr2>::_Ret _Ret;
00468   static _Ret _Answer() { return _Ret(); }
00469 };
00470 
00471 template <class _Tp1, class _Tp2, class _IsRef1, class _IsRef2>
00472 struct _OKToSwap {
00473   typedef typename _AreSameUnCVTypes<_Tp1, _Tp2>::_Ret _Same;
00474   typedef typename _Land3<_Same, _IsRef1, _IsRef2>::_Ret _Type;
00475   static _Type _Answer() { return _Type(); }
00476 };
00477 
00478 template <class _Tp1, class _Tp2, class _IsRef1, class _IsRef2>
00479 inline _OKToSwap<_Tp1, _Tp2, _IsRef1, _IsRef2>
00480 _IsOKToSwap(_Tp1*, _Tp2*, const _IsRef1&, const _IsRef2&)
00481 { return _OKToSwap<_Tp1, _Tp2, _IsRef1, _IsRef2>(); }
00482 
00483 template <class _Src, class _Dst>
00484 inline _TrivialCopy<_Src, _Dst> _UseTrivialCopy(_Src*, _Dst*)
00485 { return _TrivialCopy<_Src, _Dst>(); }
00486 
00487 template <class _Src, class _Dst>
00488 inline _TrivialUCopy<_Src, _Dst> _UseTrivialUCopy(_Src*, _Dst*)
00489 { return _TrivialUCopy<_Src, _Dst>(); }
00490 
00491 template <class _Tp>
00492 inline _TrivialInit<_Tp> _UseTrivialInit(_Tp*)
00493 { return _TrivialInit<_Tp>(); }
00494 
00495 template <class _Tp>
00496 struct _IsPOD {
00497   typedef typename __type_traits<_Tp>::is_POD_type _Type;
00498   static _Type _Answer() { return _Type(); }
00499 };
00500 
00501 template <class _Tp>
00502 inline _IsPOD<_Tp> _Is_POD(_Tp*)
00503 { return _IsPOD<_Tp>(); }
00504 
00505 template <class _Tp>
00506 struct _DefaultZeroValueQuestion {
00507   typedef typename _DefaultZeroValue<_Tp>::_Ret _Ret;
00508   static _Ret _Answer() { return _Ret(); }
00509 };
00510 
00511 template <class _Tp>
00512 inline _DefaultZeroValueQuestion<_Tp> _HasDefaultZeroValue(_Tp*)
00513 { return _DefaultZeroValueQuestion<_Tp>(); }
00514 
00515 /*
00516  * Base class used:
00517  * - to simulate partial template specialization
00518  * - to simulate partial function ordering
00519  * - to recognize STLport class from user specialized one
00520  */
00521 template <class _Tp>
00522 struct __stlport_class
00523 { typedef _Tp _Type; };
00524 
00525 template <class _Tp>
00526 struct _IsSTLportClass {
00527   typedef typename _IsConvertible<_Tp, __stlport_class<_Tp> >::_Ret _Ret;
00528 #if defined (__BORLANDC__)
00529   enum { _Is = _IsConvertible<_Tp, __stlport_class<_Tp> >::value };
00530 #endif
00531 };
00532 
00533 #if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
00534 template <class _Tp>
00535 struct _SwapImplemented {
00536   typedef typename _IsSTLportClass<_Tp>::_Ret _Ret;
00537 #  if defined (__BORLANDC__)
00538   enum { _Is = _IsSTLportClass<_Tp>::_Is };
00539 #  endif
00540 };
00541 #endif
00542 
00543 template <class _Tp>
00544 class _TpWithState : private _Tp {
00545   _TpWithState();
00546   int _state;
00547 };
00548 
00549 /* This is an internal helper struct used to guess if we are working
00550  * on a stateless class. It can only be instanciated with a class type. */
00551 template <class _Tp>
00552 struct _IsStateless {
00553   enum { _Is = sizeof(_TpWithState<_Tp>) == sizeof(int) };
00554   typedef typename __bool2type<_Is>::_Ret _Ret;
00555 };
00556 
00557 _STLP_END_NAMESPACE
00558 
00559 #ifdef _STLP_CLASS_PARTIAL_SPECIALIZATION
00560 #  if defined (__BORLANDC__) || \
00561       defined (__SUNPRO_CC) ||  \
00562      (defined (__MWERKS__) && (__MWERKS__ <= 0x2303)) || \
00563      (defined (__sgi) && defined (_COMPILER_VERSION)) || \
00564       defined (__DMC__)
00565 #    define _STLP_IS_POD_ITER(_It, _Tp) __type_traits< typename iterator_traits< _Tp >::value_type >::is_POD_type()
00566 #  else
00567 #    define _STLP_IS_POD_ITER(_It, _Tp) typename __type_traits< typename iterator_traits< _Tp >::value_type >::is_POD_type()
00568 #  endif
00569 #else
00570 #  define _STLP_IS_POD_ITER(_It, _Tp) _Is_POD( _STLP_VALUE_TYPE( _It, _Tp ) )._Answer()
00571 #endif
00572 
00573 #endif /* _STLP_TYPE_TRAITS_H */
00574 
00575 // Local Variables:
00576 // mode:C++
00577 // End:



Generated on Mon Mar 10 15:32:46 2008 by  doxygen 1.5.1