home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / stl2vac.zip / STLport-4_5_3.zip / STLport-4.5.3 / test / eh / Prefix.h < prev    next >
C/C++ Source or Header  |  2002-01-10  |  10KB  |  318 lines

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