1+ #pragma once
12#ifndef _STL_EXT_internal
23#define _STL_EXT_internal
34
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+
423using std::swap;
524
625#ifdef __BORLANDC__
@@ -69,7 +88,7 @@ class xr_vector<bool> : public std::vector<bool>
6988 void clear () { erase (begin (), end ()); }
7089};
7190
72- #else
91+ #else // M_NOSTDCONTAINERS_EXT
7392
7493template <class T >
7594class xalloc
@@ -144,20 +163,6 @@ inline bool operator!=(const xalloc<_Ty>&, const xalloc<_Other>&)
144163 return (false );
145164}
146165
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-
161166// string(char)
162167typedef std::basic_string<char , std::char_traits<char >, xalloc<char >> xr_string;
163168
@@ -245,7 +250,7 @@ class xr_deque : public std::deque<T, allocator>
245250 typedef typename allocator allocator_type;
246251 typedef typename allocator_type::value_type value_type;
247252 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 (); }
249254};
250255
251256// stack
@@ -275,44 +280,49 @@ class xr_stack
275280 _C c;
276281};
277282
283+ // instantiate the (simplest) member function in the collections, to get xalloc<T> as the default allocator.
278284template <typename T, typename allocator = xalloc<T>>
279285class xr_list : public std ::list<T, allocator>
280286{
281287public:
282- u32 size () const { return (u32 ) __super ::size (); }
288+ u32 size () const { return (u32 )std::list<T, allocator> ::size (); }
283289};
284290template <typename K, class P = std::less<K>, typename allocator = xalloc<K>>
285291class xr_set : public std ::set<K, P, allocator>
286292{
287293public:
288- u32 size () const { return (u32 ) __super ::size (); }
294+ u32 size () const { return (u32 )std::set<K, P, allocator> ::size (); }
289295};
290296template <typename K, class P = std::less<K>, typename allocator = xalloc<K>>
291297class xr_multiset : public std ::multiset<K, P, allocator>
292298{
293299public:
294- u32 size () const { return (u32 ) __super ::size (); }
300+ u32 size () const { return (u32 )std::multiset<K, P, allocator> ::size (); }
295301};
296302template <typename K, class V , class P = std::less<K>, typename allocator = xalloc<std::pair<K, V>>>
297303class xr_map : public std ::map<K, V, P, allocator>
298304{
299305public:
300- u32 size () const { return (u32 ) __super ::size (); }
306+ u32 size () const { return (u32 )std::map<K, V, P, allocator > ::size (); }
301307};
302308template <typename K, class V , class P = std::less<K>, typename allocator = xalloc<std::pair<K, V>>>
303309class xr_multimap : public std ::multimap<K, V, P, allocator>
304310{
305311public:
306- u32 size () const { return (u32 ) __super ::size (); }
312+ u32 size () const { return (u32 )std::multimap<K, V, P, allocator> ::size (); }
307313};
308314
309315#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
312317{
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+
316326template <typename V, class _HashFcn = std::hash<V>, class _EqualKey = std::equal_to<V>, typename allocator = xalloc<V>>
317327class xr_hash_multiset : public std ::hash_multiset<V, _HashFcn, _EqualKey, allocator>
318328{
@@ -335,6 +345,10 @@ class xr_hash_multimap : public std::hash_multimap<K, V, _HashFcn, _EqualKey, al
335345 u32 size () const { return (u32 ) __super ::size (); }
336346};
337347#else
348+ #ifndef _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS
349+ #define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS
350+ #endif
351+ #include < hash_map>
338352template <typename K, class V , class _Traits = stdext::hash_compare<K, std::less<K>>,
339353 typename allocator = xalloc<std::pair<K, V>>>
340354class 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>
344358};
345359#endif // #ifdef STLPORT
346360
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")
348364
349365struct pred_str : public std ::binary_function<char *, char *, bool >
350366{
351367 IC bool operator ()(const char * x, const char * y) const { return xr_strcmp (x, y) < 0 ; }
352368};
353369struct pred_stri : public std ::binary_function<char *, char *, bool >
354370{
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 ; }
356372};
357373
374+ // tamlin: TODO (low priority, for a rainy day): Rename these macros from DEFINE_* to DECLARE_*
375+
358376// STL extensions
359377#define DEF_VECTOR (N, T ) \
360378 typedef xr_vector<T> N; \
0 commit comments