Update contrib.
1 /***********************************************************************************
5 * Mark of the Unicorn, Inc.
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.
15 SUMMARY: Configuration #defines for STL EH test suite
17 ***********************************************************************************/
19 #ifndef INCLUDED_MOTU_Prefix
20 #define INCLUDED_MOTU_Prefix 1
22 // Gives much more thorough checking, but may slow the tests
23 // considerably if your malloc is slow.
24 #define TESTCLASS_DEEP_DATA 1
26 # ifndef NO_FAST_ALLOCATOR
27 // # define NO_FAST_ALLOCATOR
30 // Define this to use the SGI STL. Undefine it to test a different installation
32 # define EH_USE_SGI_STL 1
37 #define EH_ASSERT _STLP_ASSERT
39 #define _STLP_46_COMPATIBILITY
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 //=========================================================================
47 // # define _STLP_USE_RAW_SGI_ALLOCATORS
48 #ifndef _STLP_USE_NEWALLOC
49 # define _STLP_USE_NEWALLOC
52 #if 0 // !defined (_STLP_NO_CUSTOM_IO) && ! defined (__BORLANDC__)
53 # define _STLP_NO_CUSTOM_IO
56 // Just include something to get whatever configuration header we're using.
63 #if defined(_STLP_USE_NAMESPACES)
64 # define EH_USE_NAMESPACES _STLP_USE_NAMESPACES
67 #define EH_BEGIN_NAMESPACE _STLP_BEGIN_NAMESPACE
68 #define EH_END_NAMESPACE _STLP_END_NAMESPACE
70 #define EH_NEW_HEADERS 1
72 //#if defined (_STLP_USE_NEW_IOSTREAMS)
73 #define EH_NEW_IOSTREAMS 1
76 #if !defined (_STLP_USE_EXCEPTIONS)
77 # define EH_NO_EXCEPTIONS
80 #if defined (_STLP_TEMPLATE_PARAM_SUBTYPE_BUG)
81 # define EH_TEMPLATE_PARAM_SUBTYPE_BUG _STLP_TEMPLATE_PARAM_SUBTYPE_BUG
84 #if defined(_STLP_MULTI_CONST_TEMPLATE_ARG_BUG)
85 # define EH_MULTI_CONST_TEMPLATE_ARG_BUG _STLP_MULTI_CONST_TEMPLATE_ARG_BUG
89 # define EH_STD STLPORT
94 // we want to be portable here, so std:: won't work.
95 #if defined(STLPORT_CSTD)
96 # define EH_CSTD STLPORT_CSTD
101 #define EH_DISTANCE(a, b, result) EH_STD::distance(a, b, result)
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
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
117 #define stl_destroy EH_STD::destroy
121 class /*_STLP_CLASS_DECLSPEC*/ EH_allocator;
124 class /*_STLP_CLASS_DECLSPEC*/ EH_allocator {
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;
139 EH_allocator() _STLP_NOTHROW {}
140 # if defined (_STLP_MEMBER_TEMPLATES)
141 template <class _Tp1> EH_allocator(const EH_allocator<_Tp1>&) _STLP_NOTHROW {}
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;
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));
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); }
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; }
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>(); }
177 # define eh_allocator(T) ::EH_allocator<T>
179 # define EH_BIT_VECTOR_IMPLEMENTED
181 # if defined(_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined(_STLP_NO_BOOL)
182 # define EH_BIT_VECTOR EH_STD::vector<bool, eh_allocator(bool) >
184 # ifdef _STLP_NO_BOOL
185 # undef EH_BIT_VECTOR_IMPLEMENTED
187 # define EH_BIT_VECTOR EH_STD::vector<bool, eh_allocator(bool) >
191 #else // !USE_SGI_STL
192 //=========================================================================
193 // Configuration for testing other non-SGI STL implementations
194 //=========================================================================
196 // Metrowerks configuration
199 # define EH_ASSERT assert
200 // Get MSL configuration header
201 # include <ansi_parms.h>
205 # define EH_NEW_HEADERS 1
206 # if defined (_MSL_USING_NAMESPACE)
207 # define EH_USE_NAMESPACES 1
209 # define EH_BIT_VECTOR vector<bool>
210 # define EH_DISTANCE( a, b, result ) do { result = distance( a, b ); } while (0)
214 # error No configuration for earlier versions of MSL
216 # endif // __MSL__ >= 24
218 // Bugs fixed in CWPro3
219 # if __MWERKS__ < 0x2100
220 # define EH_TEMPLATE_PARAM_SUBTYPE_BUG 1
224 # if __MWERKS__ <= 0x2110
225 # define EH_MULTI_CONST_TEMPLATE_ARG_BUG 1
227 # pragma warning not sure the above bug is fixed yet
230 # define EH_SLIST_IMPLEMENTED 1
231 //# define EH_HASHED_CONTAINERS_IMPLEMENTED 1
233 # define EH_NEW_IOSTREAMS 1
234 # define EH_USE_NOTHROW 1
235 # endif // Metrowerks configuration
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
255 # define EH_STRING_IMPLEMENTED 1
256 # define EH_MULTI_CONST_TEMPLATE_ARG_BUG 1
257 # define EH_SELECT1ST_HINT select1st
259 # define stl_destroy destroy
263 // Compiler-independent configuration
265 # ifdef EH_USE_NAMESPACES
267 # define EH_STD STLPORT
272 # define EH_STD STLPORT_CSTD
276 # define EH_BEGIN_NAMESPACE namespace EH_STD {
277 # define EH_END_NAMESPACE }
279 # define EH_BEGIN_NAMESPACE
280 # define EH_END_NAMESPACE
285 # define EH_CSTD EH_STD
288 #endif // !USE_SGI_STL
292 // Library-independent configuration.
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; }
300 # define EH_SELECT1ST_HINT eh_select1st_hint
304 #if EH_USE_NAMESPACES
305 # define EH_USE_STD using namespace EH_STD;
310 #if defined (EH_USE_NAMESPACES) && !defined(_STLP_VENDOR_GLOBAL_CSTD)
311 # define USING_CSTD_NAME(name) using EH_CSTD :: name;
313 # define USING_CSTD_NAME(name)
316 #endif // INCLUDED_MOTU_Prefix