Prefix.h

00001 /***********************************************************************************
00002   Prefix.h
00003 
00004  * Copyright (c) 1997
00005  * Mark of the Unicorn, Inc.
00006  *
00007  * Permission to use, copy, modify, distribute and sell this software
00008  * and its documentation for any purpose is hereby granted without fee,
00009  * provided that the above copyright notice appear in all copies and
00010  * that both that copyright notice and this permission notice appear
00011  * in supporting documentation.  Mark of the Unicorn makes no
00012  * representations about the suitability of this software for any
00013  * purpose.  It is provided "as is" without express or implied warranty.
00014                         
00015                 SUMMARY: Configuration #defines for STL EH test suite
00016                 
00017 ***********************************************************************************/
00018 
00019 #if ! defined (INCLUDED_MOTU_Prefix)
00020 #define INCLUDED_MOTU_Prefix 1
00021 
00022 // Gives much more thorough checking, but may slow the tests
00023 // considerably if your malloc is slow.
00024 #define TESTCLASS_DEEP_DATA 1
00025 
00026 # ifndef NO_FAST_ALLOCATOR
00027 // #  define NO_FAST_ALLOCATOR
00028 # endif
00029 
00030 // Define this to use the SGI STL. Undefine it to test a different installation
00031 #ifndef EH_NO_SGI_STL
00032 # define EH_USE_SGI_STL 1
00033 #endif
00034 
00035 
00036 #if EH_USE_SGI_STL
00037 
00038 #define EH_ASSERT _STLP_ASSERT
00039 
00040 //=========================================================================
00041 // SGI STL-specific #defines
00042 //      These control the behavior of the test suite when used with the SGI
00043 //      STL. They have no effect when testing other STL implementations.
00044 //=========================================================================
00045 
00046 // # define _STLP_USE_RAW_SGI_ALLOCATORS
00047 # ifndef _STLP_USE_NEWALLOC
00048 #  define _STLP_USE_NEWALLOC
00049 # endif
00050 # if !defined  (_STLP_NO_CUSTOM_IO) && ! defined (__BORLANDC__)
00051 #  define _STLP_NO_CUSTOM_IO
00052 # endif
00053 
00054 // Just include something to get whatever configuration header we're using.
00055 # include <stl/_config.h>
00056 
00057 # ifndef _STLP_CALL
00058 #  define _STLP_CALL
00059 # endif
00060 
00061 # if defined(_STLP_USE_NAMESPACES)
00062 #  define EH_USE_NAMESPACES _STLP_USE_NAMESPACES
00063 # endif
00064 
00065 # define EH_BEGIN_NAMESPACE _STLP_BEGIN_NAMESPACE
00066 # define EH_END_NAMESPACE _STLP_END_NAMESPACE
00067 
00068 #  define EH_NEW_HEADERS 1
00069 
00070 # if defined (_STLP_USE_NEW_IOSTREAMS)
00071 #  define EH_NEW_IOSTREAMS 1
00072 # endif
00073 
00074 # if !defined (_STLP_USE_EXCEPTIONS)
00075 #  define EH_NO_EXCEPTIONS
00076 # endif
00077 
00078 # if defined (_STLP_TEMPLATE_PARAM_SUBTYPE_BUG)
00079 #  define EH_TEMPLATE_PARAM_SUBTYPE_BUG _STLP_TEMPLATE_PARAM_SUBTYPE_BUG
00080 # endif
00081 
00082 # if defined(_STLP_MULTI_CONST_TEMPLATE_ARG_BUG)
00083 #  define EH_MULTI_CONST_TEMPLATE_ARG_BUG _STLP_MULTI_CONST_TEMPLATE_ARG_BUG
00084 # endif
00085 
00086 # if defined (STLPORT)
00087 #  define EH_STD STLPORT
00088 # elif defined(__STD)
00089 #  define EH_STD __STD
00090 # endif
00091 
00092 // we want to be portable here, so std:: won't work.
00093 # if defined(STLPORT_CSTD)
00094 #  define EH_CSTD STLPORT_CSTD
00095 # else
00096 #  define EH_CSTD std
00097 # endif
00098 
00099 
00100 # define EH_DISTANCE( a, b, result ) EH_STD::distance( a, b, result )
00101 
00102 # define EH_HASHED_CONTAINERS_IMPLEMENTED 1
00103 # define EH_HASH_CONTAINERS_SUPPORT_RESIZE 1
00104 # define EH_HASH_CONTAINERS_SUPPORT_ITERATOR_CONSTRUCTION 1
00105 # define EH_SLIST_IMPLEMENTED 1
00106 # define EH_SELECT1ST_HINT __select1st_hint
00107 // fbp : DEC cxx is unable to compile it for some reason
00108 # if !( defined (__DECCXX) || (defined (__GNUC__) && (__GNUC_MINOR__ < 8) && !defined (__SYMBIAN32__)))
00109 #  define EH_ROPE_IMPLEMENTED 1
00110 # endif
00111 # define EH_STRING_IMPLEMENTED 1
00112 // # define EH_BITSET_IMPLEMENTED 1
00113 //# define EH_VALARRAY_IMPLEMENTED 1    - we have no tests yet for valarray
00114 
00115 # define stl_destroy EH_STD::destroy
00116 # include <memory>
00117 
00118 template <class _Tp>
00119 class _STLP_CLASS_DECLSPEC EH_allocator;
00120 
00121 template <class _Tp>
00122 class _STLP_CLASS_DECLSPEC EH_allocator {
00123 public:
00124 
00125   typedef _Tp        value_type;
00126   typedef value_type *       pointer;
00127   typedef const _Tp* const_pointer;
00128   typedef _Tp&       reference;
00129   typedef const _Tp& const_reference;
00130   typedef size_t     size_type;
00131   typedef ptrdiff_t  difference_type;
00132 # if defined (_STLP_MEMBER_TEMPLATE_CLASSES)
00133   template <class _Tp1> struct rebind {
00134     typedef EH_allocator<_Tp1> other;
00135   };
00136 # endif
00137   EH_allocator() _STLP_NOTHROW {}
00138  # if defined (_STLP_MEMBER_TEMPLATES)
00139   template <class _Tp1> EH_allocator(const EH_allocator<_Tp1>&) _STLP_NOTHROW {}
00140  # endif    
00141   EH_allocator(const EH_allocator<_Tp>&) _STLP_NOTHROW {}
00142   ~EH_allocator() _STLP_NOTHROW {}
00143   pointer address(reference __x) { return &__x; }
00144   const_pointer address(const_reference __x) const { return &__x; }
00145   // __n is permitted to be 0.  The C++ standard says nothing about what the return value is when __n == 0.
00146   _Tp* allocate(size_type __n, const void* = 0) const { 
00147     return __n != 0 ? __REINTERPRET_CAST(value_type*,EH_STD::__new_alloc::allocate(__n * sizeof(value_type))) : 0;
00148   }
00149   // __p is permitted to be a null pointer, only if n==0.
00150   void deallocate(pointer __p, size_type __n) const {
00151     _STLP_ASSERT( (__p == 0) == (__n == 0) )
00152       if (__p != 0) EH_STD::__new_alloc::deallocate((void*)__p, __n * sizeof(value_type));
00153   }
00154   // backwards compatibility
00155   void deallocate(pointer __p) const {  if (__p != 0) EH_STD::__new_alloc::deallocate((void*)__p, sizeof(value_type)); }
00156   size_type max_size() const _STLP_NOTHROW  { return size_t(-1) / sizeof(value_type); }
00157   void construct(pointer __p, const _Tp& __val) const { _STLP_STD::construct(__p, __val); }
00158   void destroy(pointer __p) const { _STLP_STD::destroy(__p); }
00159 
00160 };
00161 
00162 template <class _T1> inline bool  _STLP_CALL operator==(const EH_allocator<_T1>&, const EH_allocator<_T1>&)  { return true; }
00163 template <class _T1> inline bool  _STLP_CALL operator!=(const EH_allocator<_T1>&, const EH_allocator<_T1>&) { return false; }
00164 
00165 _STLP_BEGIN_NAMESPACE
00166 // If custom allocators are being used without member template classes support :
00167 // user (on purpose) is forced to define rebind/get operations !!!
00168 template <class _Tp1, class _Tp2>
00169 inline EH_allocator<_Tp2>& _STLP_CALL
00170 __stl_alloc_rebind(EH_allocator<_Tp1>& __a, const _Tp2*) {  return (EH_allocator<_Tp2>&)(__a); }
00171 template <class _Tp1, class _Tp2>
00172 inline EH_allocator<_Tp2> _STLP_CALL
00173 __stl_alloc_create(const EH_allocator<_Tp1>&, const _Tp2*) { return EH_allocator<_Tp2>(); }
00174 _STLP_END_NAMESPACE
00175 
00176 # define eh_allocator(T) ::EH_allocator<T>
00177 
00178 # define EH_BIT_VECTOR_IMPLEMENTED
00179 
00180 # if defined(_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined(_STLP_NO_BOOL)
00181 #  define EH_BIT_VECTOR EH_STD::vector<bool, eh_allocator(bool) >
00182 # else
00183 #  ifdef _STLP_NO_BOOL
00184 #  undef   EH_BIT_VECTOR_IMPLEMENTED
00185 #  else
00186 #   define EH_BIT_VECTOR EH_STD::__vector__<bool, eh_allocator(bool) >
00187 #  endif
00188 # endif
00189 
00190 #else // !USE_SGI_STL
00191 //=========================================================================
00192 // Configuration for testing other non-SGI STL implementations
00193 //=========================================================================
00194 
00195 // Metrowerks configuration
00196 # ifdef __MWERKS__
00197 
00198 # define EH_ASSERT assert
00199 // Get MSL configuration header
00200 #  include <ansi_parms.h>
00201 
00202 #  if __MSL__ >= 24
00203 
00204 #   define EH_NEW_HEADERS 1
00205 #   if defined (_MSL_USING_NAMESPACE)
00206 #    define EH_USE_NAMESPACES 1
00207 #   endif
00208 #       define EH_BIT_VECTOR vector<bool>
00209 #   define EH_DISTANCE( a, b, result ) do { result = distance( a, b ); } while (0)
00210 
00211 #  else
00212 
00213 #   error No configuration for earlier versions of MSL
00214 
00215 #  endif        // __MSL__ >= 24
00216 
00217 // Bugs fixed in CWPro3
00218 #  if __MWERKS__ < 0x2100
00219 #   define EH_TEMPLATE_PARAM_SUBTYPE_BUG 1
00220 #  endif
00221 
00222 // Bugs in CWPro3
00223 #  if __MWERKS__ <= 0x2110
00224 #   define EH_MULTI_CONST_TEMPLATE_ARG_BUG 1
00225 #  else
00226 #   pragma warning not sure the above bug is fixed yet
00227 #  endif
00228 
00229 #  define EH_SLIST_IMPLEMENTED 1
00230 //#  define EH_HASHED_CONTAINERS_IMPLEMENTED 1
00231 
00232 #  define EH_NEW_IOSTREAMS 1
00233 #  define EH_USE_NOTHROW 1
00234 # endif // Metrowerks configuration
00235 
00236 #if defined (__SUNPRO_CC)
00237 # define stl_destroy __RWSTD::__destroy
00238 # define EH_DISTANCE( a, b, result ) distance( a, b, result )
00239 # define EH_BIT_VECTOR EH_STD::vector<bool>
00240 # define EH_NEW_HEADERS 1
00241 # define EH_USE_NAMESPACES 1
00242 # define EH_NEW_IOSTREAMS 1
00243 # define EH_ASSERT assert
00244 # define EH_STRING_IMPLEMENTED 1
00245 # elif defined (__KCC)
00246 # define stl_destroy EH_STD::destroy
00247 # define EH_DISTANCE( a, b, result ) do { result = distance( a, b ); } while (0)
00248 # define EH_BIT_VECTOR EH_STD::vector<bool>
00249 # define EH_NEW_HEADERS 1
00250 # define EH_USE_NAMESPACES 1
00251 # define EH_NEW_IOSTREAMS 1
00252 # define EH_ASSERT assert
00253 # define EH_CSTD
00254 # define EH_STRING_IMPLEMENTED 1
00255 # define EH_MULTI_CONST_TEMPLATE_ARG_BUG 1
00256 # define EH_SELECT1ST_HINT select1st
00257 # else
00258 # define stl_destroy destroy
00259 #endif
00260 
00261 //
00262 // Compiler-independent configuration
00263 //
00264 # ifdef EH_USE_NAMESPACES
00265 # ifdef STLPORT
00266 #  define EH_STD STLPORT
00267 # else
00268 #  define EH_STD std
00269 # endif
00270 # ifdef STLPORT_CSTD
00271 #  define EH_STD STLPORT_CSTD
00272 # else
00273 #  define EH_STD std
00274 # endif
00275 #  define EH_BEGIN_NAMESPACE namespace EH_STD {
00276 #  define EH_END_NAMESPACE   }
00277 # else
00278 #  define EH_BEGIN_NAMESPACE
00279 #  define EH_END_NAMESPACE
00280 #  define EH_STD
00281 # endif
00282 
00283 # ifndef EH_CSTD
00284 #  define EH_CSTD EH_STD
00285 # endif
00286 
00287 #endif // !USE_SGI_STL
00288 
00289 
00290 //
00291 // Library-independent configuration.
00292 //
00293 #if defined( EH_MULTI_CONST_TEMPLATE_ARG_BUG) && !defined( EH_SELECT1ST_HINT )
00294 template <class Pair, class U>          
00295 // JDJ (CW Pro1 doesn't like const when first_type is also const)
00296 struct eh_select1st_hint : public unary_function<Pair, U> {
00297     const U& operator () (const Pair& x) const { return x.first; }
00298 };
00299 # define EH_SELECT1ST_HINT eh_select1st_hint
00300 #endif
00301 
00302 
00303 #if EH_USE_NAMESPACES
00304 # define EH_USE_STD using namespace EH_STD;
00305 #else
00306 # define EH_USE_STD
00307 #endif
00308 
00309 #if defined (EH_USE_NAMESPACES) && !defined(_STLP_VENDOR_GLOBAL_CSTD)
00310 # define USING_CSTD_NAME(name) using EH_STD :: name;
00311 #else
00312 # define USING_CSTD_NAME(name)
00313 #endif
00314 
00315 #endif // INCLUDED_MOTU_Prefix
00316 
00317 

Generated on Mon Jun 5 10:20:48 2006 for Intelligence.kdevelop by  doxygen 1.4.6