1
+ #pragma once
1
2
#ifndef _STL_EXT_internal
2
3
#define _STL_EXT_internal
3
4
5
+ #include < string>
6
+ #include < vector>
7
+ #include < deque>
8
+ #include < list>
9
+ #include < set>
10
+ #include < map>
11
+ #include " _types.h"
12
+ #include " _rect.h"
13
+ #include " _plane.h"
14
+ #include " _vector2.h"
15
+ #include " _vector3d.h"
16
+ #include " _color.h"
17
+ #include " _std_extensions.h"
18
+ #include " xrMemory.h"
19
+ #include " xrDebug_macros.h" // only for pragma todo. Remove once handled.
20
+
21
+ #pragma todo("tamlin: This header includes pretty much every std collection there are. Compiler-hog! FIX!")
22
+
4
23
using std::swap;
5
24
6
25
#ifdef __BORLANDC__
@@ -69,7 +88,7 @@ class xr_vector<bool> : public std::vector<bool>
69
88
void clear () { erase (begin (), end ()); }
70
89
};
71
90
72
- #else
91
+ #else // M_NOSTDCONTAINERS_EXT
73
92
74
93
template <class T >
75
94
class xalloc
@@ -144,20 +163,6 @@ inline bool operator!=(const xalloc<_Ty>&, const xalloc<_Other>&)
144
163
return (false );
145
164
}
146
165
147
- namespace std
148
- {
149
- template <class _Tp1 , class _Tp2 >
150
- inline xalloc<_Tp2>& __stl_alloc_rebind (xalloc<_Tp1>& __a, const _Tp2*)
151
- {
152
- return (xalloc<_Tp2>&)(__a);
153
- }
154
- template <class _Tp1 , class _Tp2 >
155
- inline xalloc<_Tp2> __stl_alloc_create (xalloc<_Tp1>&, const _Tp2*)
156
- {
157
- return xalloc<_Tp2>();
158
- }
159
- };
160
-
161
166
// string(char)
162
167
typedef std::basic_string<char , std::char_traits<char >, xalloc<char >> xr_string;
163
168
@@ -245,7 +250,7 @@ class xr_deque : public std::deque<T, allocator>
245
250
typedef typename allocator allocator_type;
246
251
typedef typename allocator_type::value_type value_type;
247
252
typedef typename allocator_type::size_type size_type;
248
- u32 size () const { return (u32 ) __super ::size (); }
253
+ u32 size () const { return (u32 )std::deque<T, allocator> ::size (); }
249
254
};
250
255
251
256
// stack
@@ -275,44 +280,49 @@ class xr_stack
275
280
_C c;
276
281
};
277
282
283
+ // instantiate the (simplest) member function in the collections, to get xalloc<T> as the default allocator.
278
284
template <typename T, typename allocator = xalloc<T>>
279
285
class xr_list : public std ::list<T, allocator>
280
286
{
281
287
public:
282
- u32 size () const { return (u32 ) __super ::size (); }
288
+ u32 size () const { return (u32 )std::list<T, allocator> ::size (); }
283
289
};
284
290
template <typename K, class P = std::less<K>, typename allocator = xalloc<K>>
285
291
class xr_set : public std ::set<K, P, allocator>
286
292
{
287
293
public:
288
- u32 size () const { return (u32 ) __super ::size (); }
294
+ u32 size () const { return (u32 )std::set<K, P, allocator> ::size (); }
289
295
};
290
296
template <typename K, class P = std::less<K>, typename allocator = xalloc<K>>
291
297
class xr_multiset : public std ::multiset<K, P, allocator>
292
298
{
293
299
public:
294
- u32 size () const { return (u32 ) __super ::size (); }
300
+ u32 size () const { return (u32 )std::multiset<K, P, allocator> ::size (); }
295
301
};
296
302
template <typename K, class V , class P = std::less<K>, typename allocator = xalloc<std::pair<K, V>>>
297
303
class xr_map : public std ::map<K, V, P, allocator>
298
304
{
299
305
public:
300
- u32 size () const { return (u32 ) __super ::size (); }
306
+ u32 size () const { return (u32 )std::map<K, V, P, allocator > ::size (); }
301
307
};
302
308
template <typename K, class V , class P = std::less<K>, typename allocator = xalloc<std::pair<K, V>>>
303
309
class xr_multimap : public std ::multimap<K, V, P, allocator>
304
310
{
305
311
public:
306
- u32 size () const { return (u32 ) __super ::size (); }
312
+ u32 size () const { return (u32 )std::multimap<K, V, P, allocator> ::size (); }
307
313
};
308
314
309
315
#ifdef STLPORT
310
- template <typename V, class _HashFcn = std::hash<V>, class _EqualKey = std::equal_to<V>, typename allocator = xalloc<V>>
311
- class xr_hash_set : public std ::hash_set<V, _HashFcn, _EqualKey, allocator>
316
+ namespace std
312
317
{
313
- public:
314
- u32 size () const { return (u32 ) __super ::size (); }
315
- };
318
+ template <class _Tp1 , class _Tp2 >
319
+ inline xalloc<_Tp2>& __stl_alloc_rebind (xalloc<_Tp1>& __a, const _Tp2*)
320
+ { return (xalloc<_Tp2>&)(__a); }
321
+ template <class _Tp1 , class _Tp2 >
322
+ inline xalloc<_Tp2> __stl_alloc_create (xalloc<_Tp1>&, const _Tp2*)
323
+ { return xalloc<_Tp2>(); }
324
+ }
325
+
316
326
template <typename V, class _HashFcn = std::hash<V>, class _EqualKey = std::equal_to<V>, typename allocator = xalloc<V>>
317
327
class xr_hash_multiset : public std ::hash_multiset<V, _HashFcn, _EqualKey, allocator>
318
328
{
@@ -335,6 +345,10 @@ class xr_hash_multimap : public std::hash_multimap<K, V, _HashFcn, _EqualKey, al
335
345
u32 size () const { return (u32 ) __super ::size (); }
336
346
};
337
347
#else
348
+ #ifndef _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS
349
+ #define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS
350
+ #endif
351
+ #include < hash_map>
338
352
template <typename K, class V , class _Traits = stdext::hash_compare<K, std::less<K>>,
339
353
typename allocator = xalloc<std::pair<K, V>>>
340
354
class xr_hash_map : public stdext ::hash_map<K, V, _Traits, allocator>
@@ -344,17 +358,21 @@ class xr_hash_map : public stdext::hash_map<K, V, _Traits, allocator>
344
358
};
345
359
#endif // #ifdef STLPORT
346
360
347
- #endif
361
+ #endif // M_NOSTDCONTAINERS_EXT
362
+
363
+ #pragma todo("tamlin: Why define our own mk_pair? What's wrong with std::make_pair")
348
364
349
365
struct pred_str : public std ::binary_function<char *, char *, bool >
350
366
{
351
367
IC bool operator ()(const char * x, const char * y) const { return xr_strcmp (x, y) < 0 ; }
352
368
};
353
369
struct pred_stri : public std ::binary_function<char *, char *, bool >
354
370
{
355
- IC bool operator ()(const char * x, const char * y) const { return stricmp (x, y) < 0 ; }
371
+ IC bool operator ()(const char * x, const char * y) const { return _stricmp (x, y) < 0 ; }
356
372
};
357
373
374
+ // tamlin: TODO (low priority, for a rainy day): Rename these macros from DEFINE_* to DECLARE_*
375
+
358
376
// STL extensions
359
377
#define DEF_VECTOR (N, T ) \
360
378
typedef xr_vector<T> N; \
0 commit comments