genericopenlibs/cppstdlib/stl/test/eh/Prefix.h
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 /***********************************************************************************
       
     2   Prefix.h
       
     3 
       
     4  * Copyright (c) 1997
       
     5  * Mark of the Unicorn, Inc.
       
     6  *
       
     7  * Permission to use, copy, modify, distribute and sell this software
       
     8  * and its documentation for any purpose is hereby granted without fee,
       
     9  * provided that the above copyright notice appear in all copies and
       
    10  * that both that copyright notice and this permission notice appear
       
    11  * in supporting documentation.  Mark of the Unicorn makes no
       
    12  * representations about the suitability of this software for any
       
    13  * purpose.  It is provided "as is" without express or implied warranty.
       
    14 
       
    15     SUMMARY: Configuration #defines for STL EH test suite
       
    16 
       
    17 ***********************************************************************************/
       
    18 
       
    19 #ifndef INCLUDED_MOTU_Prefix
       
    20 #define INCLUDED_MOTU_Prefix 1
       
    21 
       
    22 // Gives much more thorough checking, but may slow the tests
       
    23 // considerably if your malloc is slow.
       
    24 #define TESTCLASS_DEEP_DATA 1
       
    25 
       
    26 # ifndef NO_FAST_ALLOCATOR
       
    27 // #  define NO_FAST_ALLOCATOR
       
    28 # endif
       
    29 
       
    30 // Define this to use the SGI STL. Undefine it to test a different installation
       
    31 #ifndef EH_NO_SGI_STL
       
    32 # define EH_USE_SGI_STL 1
       
    33 #endif
       
    34 
       
    35 #if EH_USE_SGI_STL
       
    36 
       
    37 #define EH_ASSERT _STLP_ASSERT
       
    38 
       
    39 #define _STLP_46_COMPATIBILITY
       
    40 
       
    41 //=========================================================================
       
    42 // SGI STL-specific #defines
       
    43 //  These control the behavior of the test suite when used with the SGI
       
    44 //  STL. They have no effect when testing other STL implementations.
       
    45 //=========================================================================
       
    46 
       
    47 // # define _STLP_USE_RAW_SGI_ALLOCATORS
       
    48 #ifndef _STLP_USE_NEWALLOC
       
    49 #  define _STLP_USE_NEWALLOC
       
    50 #endif
       
    51 
       
    52 #if 0 // !defined  (_STLP_NO_CUSTOM_IO) && ! defined (__BORLANDC__)
       
    53 #  define _STLP_NO_CUSTOM_IO
       
    54 #endif
       
    55 
       
    56 // Just include something to get whatever configuration header we're using.
       
    57 #include <utility>
       
    58 
       
    59 #ifndef _STLP_CALL
       
    60 #  define _STLP_CALL
       
    61 #endif
       
    62 
       
    63 #if defined(_STLP_USE_NAMESPACES)
       
    64 #  define EH_USE_NAMESPACES _STLP_USE_NAMESPACES
       
    65 #endif
       
    66 
       
    67 #define EH_BEGIN_NAMESPACE _STLP_BEGIN_NAMESPACE
       
    68 #define EH_END_NAMESPACE _STLP_END_NAMESPACE
       
    69 
       
    70 #define EH_NEW_HEADERS 1
       
    71 
       
    72 //#if defined (_STLP_USE_NEW_IOSTREAMS)
       
    73 #define EH_NEW_IOSTREAMS 1
       
    74 //#endif
       
    75 
       
    76 #if !defined (_STLP_USE_EXCEPTIONS)
       
    77 #  define EH_NO_EXCEPTIONS
       
    78 #endif
       
    79 
       
    80 #if defined (_STLP_TEMPLATE_PARAM_SUBTYPE_BUG)
       
    81 #  define EH_TEMPLATE_PARAM_SUBTYPE_BUG _STLP_TEMPLATE_PARAM_SUBTYPE_BUG
       
    82 #endif
       
    83 
       
    84 #if defined(_STLP_MULTI_CONST_TEMPLATE_ARG_BUG)
       
    85 #  define EH_MULTI_CONST_TEMPLATE_ARG_BUG _STLP_MULTI_CONST_TEMPLATE_ARG_BUG
       
    86 #endif
       
    87 
       
    88 #if defined (STLPORT)
       
    89 #  define EH_STD STLPORT
       
    90 #elif defined(__STD)
       
    91 #  define EH_STD __STD
       
    92 #endif
       
    93 
       
    94 // we want to be portable here, so std:: won't work.
       
    95 #if defined(STLPORT_CSTD)
       
    96 #  define EH_CSTD STLPORT_CSTD
       
    97 #else
       
    98 #  define EH_CSTD std
       
    99 #endif
       
   100 
       
   101 #define EH_DISTANCE(a, b, result) EH_STD::distance(a, b, result)
       
   102 
       
   103 #define EH_HASHED_CONTAINERS_IMPLEMENTED 1
       
   104 #define EH_HASH_CONTAINERS_SUPPORT_RESIZE 1
       
   105 #define EH_HASH_CONTAINERS_SUPPORT_ITERATOR_CONSTRUCTION 1
       
   106 #define EH_SLIST_IMPLEMENTED 1
       
   107 #define EH_SELECT1ST_HINT __select1st_hint
       
   108 // fbp : DEC cxx is unable to compile it for some reason
       
   109 #if !(defined (__DECCXX)  || defined (__amigaos__) || \
       
   110       (defined (__GNUC__) && (__GNUC__ <= 2) && (__GNUC_MINOR__ < 8)))
       
   111 #  define EH_ROPE_IMPLEMENTED 1
       
   112 #endif
       
   113 #define EH_STRING_IMPLEMENTED 1
       
   114 // # define EH_BITSET_IMPLEMENTED 1
       
   115 //# define EH_VALARRAY_IMPLEMENTED 1  - we have no tests yet for valarray
       
   116 
       
   117 #define stl_destroy EH_STD::destroy
       
   118 #include <memory>
       
   119 
       
   120 template <class _Tp>
       
   121 class /*_STLP_CLASS_DECLSPEC*/ EH_allocator;
       
   122 
       
   123 template <class _Tp>
       
   124 class /*_STLP_CLASS_DECLSPEC*/ EH_allocator {
       
   125 public:
       
   126 
       
   127   typedef _Tp        value_type;
       
   128   typedef value_type *       pointer;
       
   129   typedef const _Tp* const_pointer;
       
   130   typedef _Tp&       reference;
       
   131   typedef const _Tp& const_reference;
       
   132   typedef EH_CSTD::size_t     size_type;
       
   133   typedef EH_CSTD::ptrdiff_t  difference_type;
       
   134 # if defined (_STLP_MEMBER_TEMPLATE_CLASSES)
       
   135   template <class _Tp1> struct rebind {
       
   136     typedef EH_allocator<_Tp1> other;
       
   137   };
       
   138 # endif
       
   139   EH_allocator() _STLP_NOTHROW {}
       
   140  # if defined (_STLP_MEMBER_TEMPLATES)
       
   141   template <class _Tp1> EH_allocator(const EH_allocator<_Tp1>&) _STLP_NOTHROW {}
       
   142  # endif
       
   143   EH_allocator(const EH_allocator<_Tp>&) _STLP_NOTHROW {}
       
   144   ~EH_allocator() _STLP_NOTHROW {}
       
   145   pointer address(reference __x) { return &__x; }
       
   146   const_pointer address(const_reference __x) const { return &__x; }
       
   147   // __n is permitted to be 0.  The C++ standard says nothing about what the return value is when __n == 0.
       
   148   _Tp* allocate(size_type __n, const void* = 0) const {
       
   149     return __n != 0 ? __REINTERPRET_CAST(value_type*,EH_STD::__new_alloc::allocate(__n * sizeof(value_type))) : 0;
       
   150   }
       
   151   // __p is permitted to be a null pointer, only if n==0.
       
   152   void deallocate(pointer __p, size_type __n) const {
       
   153     _STLP_ASSERT( (__p == 0) == (__n == 0) )
       
   154       if (__p != 0) EH_STD::__new_alloc::deallocate((void*)__p, __n * sizeof(value_type));
       
   155   }
       
   156   // backwards compatibility
       
   157   void deallocate(pointer __p) const {  if (__p != 0) EH_STD::__new_alloc::deallocate((void*)__p, sizeof(value_type)); }
       
   158   size_type max_size() const _STLP_NOTHROW  { return size_t(-1) / sizeof(value_type); }
       
   159   void construct(pointer __p, const _Tp& __val) const { stlport::construct(__p, __val); }
       
   160   void destroy(pointer __p) const { stlport::destroy(__p); }
       
   161 };
       
   162 
       
   163 template <class _T1> inline bool  _STLP_CALL operator==(const EH_allocator<_T1>&, const EH_allocator<_T1>&)  { return true; }
       
   164 template <class _T1> inline bool  _STLP_CALL operator!=(const EH_allocator<_T1>&, const EH_allocator<_T1>&) { return false; }
       
   165 
       
   166 _STLP_BEGIN_NAMESPACE
       
   167 // If custom allocators are being used without member template classes support :
       
   168 // user (on purpose) is forced to define rebind/get operations !!!
       
   169 template <class _Tp1, class _Tp2>
       
   170 inline EH_allocator<_Tp2>& _STLP_CALL
       
   171 __stl_alloc_rebind(EH_allocator<_Tp1>& __a, const _Tp2*) {  return (EH_allocator<_Tp2>&)(__a); }
       
   172 template <class _Tp1, class _Tp2>
       
   173 inline EH_allocator<_Tp2> _STLP_CALL
       
   174 __stl_alloc_create(const EH_allocator<_Tp1>&, const _Tp2*) { return EH_allocator<_Tp2>(); }
       
   175 _STLP_END_NAMESPACE
       
   176 
       
   177 # define eh_allocator(T) ::EH_allocator<T>
       
   178 
       
   179 # define EH_BIT_VECTOR_IMPLEMENTED
       
   180 
       
   181 # if defined(_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined(_STLP_NO_BOOL)
       
   182 #  define EH_BIT_VECTOR EH_STD::vector<bool, eh_allocator(bool) >
       
   183 # else
       
   184 #  ifdef _STLP_NO_BOOL
       
   185 #  undef   EH_BIT_VECTOR_IMPLEMENTED
       
   186 #  else
       
   187 #   define EH_BIT_VECTOR EH_STD::vector<bool, eh_allocator(bool) >
       
   188 #  endif
       
   189 # endif
       
   190 
       
   191 #else // !USE_SGI_STL
       
   192 //=========================================================================
       
   193 // Configuration for testing other non-SGI STL implementations
       
   194 //=========================================================================
       
   195 
       
   196 // Metrowerks configuration
       
   197 # ifdef __MWERKS__
       
   198 
       
   199 # define EH_ASSERT assert
       
   200 // Get MSL configuration header
       
   201 #  include <ansi_parms.h>
       
   202 
       
   203 #  if __MSL__ >= 24
       
   204 
       
   205 #   define EH_NEW_HEADERS 1
       
   206 #   if defined (_MSL_USING_NAMESPACE)
       
   207 #    define EH_USE_NAMESPACES 1
       
   208 #   endif
       
   209 #  define EH_BIT_VECTOR vector<bool>
       
   210 #   define EH_DISTANCE( a, b, result ) do { result = distance( a, b ); } while (0)
       
   211 
       
   212 #  else
       
   213 
       
   214 #   error No configuration for earlier versions of MSL
       
   215 
       
   216 #  endif  // __MSL__ >= 24
       
   217 
       
   218 // Bugs fixed in CWPro3
       
   219 #  if __MWERKS__ < 0x2100
       
   220 #   define EH_TEMPLATE_PARAM_SUBTYPE_BUG 1
       
   221 #  endif
       
   222 
       
   223 // Bugs in CWPro3
       
   224 #  if __MWERKS__ <= 0x2110
       
   225 #   define EH_MULTI_CONST_TEMPLATE_ARG_BUG 1
       
   226 #  else
       
   227 #   pragma warning not sure the above bug is fixed yet
       
   228 #  endif
       
   229 
       
   230 #  define EH_SLIST_IMPLEMENTED 1
       
   231 //#  define EH_HASHED_CONTAINERS_IMPLEMENTED 1
       
   232 
       
   233 #  define EH_NEW_IOSTREAMS 1
       
   234 #  define EH_USE_NOTHROW 1
       
   235 # endif // Metrowerks configuration
       
   236 
       
   237 #if defined (__SUNPRO_CC)
       
   238 # define stl_destroy __RWSTD::__destroy
       
   239 # define EH_DISTANCE( a, b, result ) distance( a, b, result )
       
   240 # define EH_BIT_VECTOR EH_STD::vector<bool>
       
   241 # define EH_NEW_HEADERS 1
       
   242 # define EH_USE_NAMESPACES 1
       
   243 # define EH_NEW_IOSTREAMS 1
       
   244 # define EH_ASSERT assert
       
   245 # define EH_STRING_IMPLEMENTED 1
       
   246 # elif defined (__KCC)
       
   247 # define stl_destroy EH_STD::destroy
       
   248 # define EH_DISTANCE( a, b, result ) do { result = distance( a, b ); } while (0)
       
   249 # define EH_BIT_VECTOR EH_STD::vector<bool>
       
   250 # define EH_NEW_HEADERS 1
       
   251 # define EH_USE_NAMESPACES 1
       
   252 # define EH_NEW_IOSTREAMS 1
       
   253 # define EH_ASSERT assert
       
   254 # define EH_CSTD
       
   255 # define EH_STRING_IMPLEMENTED 1
       
   256 # define EH_MULTI_CONST_TEMPLATE_ARG_BUG 1
       
   257 # define EH_SELECT1ST_HINT select1st
       
   258 # else
       
   259 # define stl_destroy destroy
       
   260 #endif
       
   261 
       
   262 //
       
   263 // Compiler-independent configuration
       
   264 //
       
   265 # ifdef EH_USE_NAMESPACES
       
   266 # ifdef STLPORT
       
   267 #  define EH_STD STLPORT
       
   268 # else
       
   269 #  define EH_STD std
       
   270 # endif
       
   271 # ifdef STLPORT_CSTD
       
   272 #  define EH_STD STLPORT_CSTD
       
   273 # else
       
   274 #  define EH_STD std
       
   275 # endif
       
   276 #  define EH_BEGIN_NAMESPACE namespace EH_STD {
       
   277 #  define EH_END_NAMESPACE   }
       
   278 # else
       
   279 #  define EH_BEGIN_NAMESPACE
       
   280 #  define EH_END_NAMESPACE
       
   281 #  define EH_STD
       
   282 # endif
       
   283 
       
   284 # ifndef EH_CSTD
       
   285 #  define EH_CSTD EH_STD
       
   286 # endif
       
   287 
       
   288 #endif // !USE_SGI_STL
       
   289 
       
   290 
       
   291 //
       
   292 // Library-independent configuration.
       
   293 //
       
   294 #if defined( EH_MULTI_CONST_TEMPLATE_ARG_BUG) && !defined( EH_SELECT1ST_HINT )
       
   295 template <class Pair, class U>
       
   296 // JDJ (CW Pro1 doesn't like const when first_type is also const)
       
   297 struct eh_select1st_hint : public unary_function<Pair, U> {
       
   298     const U& operator () (const Pair& x) const { return x.first; }
       
   299 };
       
   300 # define EH_SELECT1ST_HINT eh_select1st_hint
       
   301 #endif
       
   302 
       
   303 
       
   304 #if EH_USE_NAMESPACES
       
   305 # define EH_USE_STD using namespace EH_STD;
       
   306 #else
       
   307 # define EH_USE_STD
       
   308 #endif
       
   309 
       
   310 #if defined (EH_USE_NAMESPACES) && !defined(_STLP_VENDOR_GLOBAL_CSTD)
       
   311 # define USING_CSTD_NAME(name) using EH_CSTD :: name;
       
   312 #else
       
   313 # define USING_CSTD_NAME(name)
       
   314 #endif
       
   315 
       
   316 #endif // INCLUDED_MOTU_Prefix