diff --git a/src/xrCore/_stl_extensions.h b/src/xrCore/_stl_extensions.h index 0d9bfeddab8..21cc353d813 100644 --- a/src/xrCore/_stl_extensions.h +++ b/src/xrCore/_stl_extensions.h @@ -1,6 +1,25 @@ +#pragma once #ifndef _STL_EXT_internal #define _STL_EXT_internal +#include +#include +#include +#include +#include +#include +#include "_types.h" +#include "_rect.h" +#include "_plane.h" +#include "_vector2.h" +#include "_vector3d.h" +#include "_color.h" +#include "_std_extensions.h" +#include "xrMemory.h" +#include "xrDebug_macros.h" // only for pragma todo. Remove once handled. + +#pragma todo("tamlin: This header includes pretty much every std collection there are. Compiler-hog! FIX!") + using std::swap; #ifdef __BORLANDC__ @@ -69,7 +88,7 @@ class xr_vector : public std::vector void clear() { erase(begin(), end()); } }; -#else +#else // M_NOSTDCONTAINERS_EXT template class xalloc @@ -144,20 +163,6 @@ inline bool operator!=(const xalloc<_Ty>&, const xalloc<_Other>&) return (false); } -namespace std -{ -template -inline xalloc<_Tp2>& __stl_alloc_rebind(xalloc<_Tp1>& __a, const _Tp2*) -{ - return (xalloc<_Tp2>&)(__a); -} -template -inline xalloc<_Tp2> __stl_alloc_create(xalloc<_Tp1>&, const _Tp2*) -{ - return xalloc<_Tp2>(); -} -}; - // string(char) typedef std::basic_string, xalloc> xr_string; @@ -245,7 +250,7 @@ class xr_deque : public std::deque typedef typename allocator allocator_type; typedef typename allocator_type::value_type value_type; typedef typename allocator_type::size_type size_type; - u32 size() const { return (u32) __super ::size(); } + u32 size() const { return (u32)std::deque::size(); } }; // stack @@ -275,44 +280,49 @@ class xr_stack _C c; }; +// instantiate the (simplest) member function in the collections, to get xalloc as the default allocator. template > class xr_list : public std::list { public: - u32 size() const { return (u32) __super ::size(); } + u32 size() const { return (u32)std::list::size(); } }; template , typename allocator = xalloc> class xr_set : public std::set { public: - u32 size() const { return (u32) __super ::size(); } + u32 size() const { return (u32)std::set::size(); } }; template , typename allocator = xalloc> class xr_multiset : public std::multiset { public: - u32 size() const { return (u32) __super ::size(); } + u32 size() const { return (u32)std::multiset::size(); } }; template , typename allocator = xalloc>> class xr_map : public std::map { public: - u32 size() const { return (u32) __super ::size(); } + u32 size() const { return (u32)std::map::size(); } }; template , typename allocator = xalloc>> class xr_multimap : public std::multimap { public: - u32 size() const { return (u32) __super ::size(); } + u32 size() const { return (u32)std::multimap::size(); } }; #ifdef STLPORT -template , class _EqualKey = std::equal_to, typename allocator = xalloc> -class xr_hash_set : public std::hash_set +namespace std { -public: - u32 size() const { return (u32) __super ::size(); } -}; + template + inline xalloc<_Tp2>& __stl_alloc_rebind(xalloc<_Tp1>& __a, const _Tp2*) + { return (xalloc<_Tp2>&)(__a); } + template + inline xalloc<_Tp2> __stl_alloc_create(xalloc<_Tp1>&, const _Tp2*) + { return xalloc<_Tp2>(); } +} + template , class _EqualKey = std::equal_to, typename allocator = xalloc> class xr_hash_multiset : public std::hash_multiset { @@ -335,6 +345,10 @@ class xr_hash_multimap : public std::hash_multimap template >, typename allocator = xalloc>> class xr_hash_map : public stdext::hash_map @@ -344,7 +358,9 @@ class xr_hash_map : public stdext::hash_map }; #endif // #ifdef STLPORT -#endif +#endif // M_NOSTDCONTAINERS_EXT + +#pragma todo("tamlin: Why define our own mk_pair? What's wrong with std::make_pair") struct pred_str : public std::binary_function { @@ -352,9 +368,11 @@ struct pred_str : public std::binary_function }; struct pred_stri : public std::binary_function { - IC bool operator()(const char* x, const char* y) const { return stricmp(x, y) < 0; } + IC bool operator()(const char* x, const char* y) const { return _stricmp(x, y) < 0; } }; +// tamlin: TODO (low priority, for a rainy day): Rename these macros from DEFINE_* to DECLARE_* + // STL extensions #define DEF_VECTOR(N, T) \ typedef xr_vector N; \