#include "wx/string.h"
#include "wx/wxcrt.h"
+// In wxUSE_STL build we prefer to use the standard hash map class but it can
+// be either in non-standard hash_map header (old g++ and some other STL
+// implementations) or in C++0x standard unordered_map which can in turn be
+// available either in std::tr1 or std namespace itself
+//
+// To summarize: if std::unordered_map is available use it, otherwise use tr1
+// and finally fall back to non-standard hash_map
+
#if (defined(HAVE_EXT_HASH_MAP) || defined(HAVE_HASH_MAP)) \
&& (defined(HAVE_GNU_CXX_HASH_MAP) || defined(HAVE_STD_HASH_MAP))
#define HAVE_STL_HASH_MAP
#endif
-#if wxUSE_STL && defined(HAVE_STL_HASH_MAP)
+#if wxUSE_STL && \
+ (defined(HAVE_STD_UNORDERED_MAP) || defined(HAVE_TR1_UNORDERED_MAP))
+
+#if defined(HAVE_STD_UNORDERED_MAP)
+ #include <unordered_map>
+ #define WX_HASH_MAP_NAMESPACE std
+#elif defined(HAVE_TR1_UNORDERED_MAP)
+ #include <tr1/unordered_map>
+ #define WX_HASH_MAP_NAMESPACE std::tr1
+#endif
+
+#define _WX_DECLARE_HASH_MAP( KEY_T, VALUE_T, HASH_T, KEY_EQ_T, CLASSNAME, CLASSEXP ) \
+ typedef WX_HASH_MAP_NAMESPACE::unordered_map< KEY_T, VALUE_T, HASH_T, KEY_EQ_T > CLASSNAME
+
+#elif wxUSE_STL && defined(HAVE_STL_HASH_MAP)
#if defined(HAVE_EXT_HASH_MAP)
#include <ext/hash_map>
#define _WX_DECLARE_HASH_MAP( KEY_T, VALUE_T, HASH_T, KEY_EQ_T, CLASSNAME, CLASSEXP ) \
typedef WX_HASH_MAP_NAMESPACE::hash_map< KEY_T, VALUE_T, HASH_T, KEY_EQ_T > CLASSNAME
-#else // !wxUSE_STL || !defined(HAVE_STL_HASH_MAP)
+#else // !wxUSE_STL || no std::{hash,unordered}_map class available
+#define wxNEEDS_WX_HASH_MAP
#ifdef __WXWINCE__
typedef int ptrdiff_t;
CLASSEXP CLASSNAME \
{ \
public: \
+ typedef KEY_T first_type; \
+ typedef VALUE_T second_type; \
typedef KEY_T t1; \
typedef VALUE_T t2; \
typedef const KEY_T const_t1; \
return float(items)/float(buckets) >= 0.85;
}
-#endif // !wxUSE_STL || !defined(HAVE_STL_HASH_MAP)
+#endif // various hash map implementations
// ----------------------------------------------------------------------------
// hashing and comparison functors
// operators to suppress warnings about "statement with no effect" from gcc
// in the hash table class assignment operator (where they're assigned)
-#if wxUSE_STL && defined(HAVE_STL_HASH_MAP)
+#ifndef wxNEEDS_WX_HASH_MAP
// integer types
class WXDLLIMPEXP_BASE wxIntegerHash
wxIntegerHash& operator=(const wxIntegerHash&) { return *this; }
};
-#else // !wxUSE_STL || !defined(HAVE_STL_HASH_MAP)
+#else // wxNEEDS_WX_HASH_MAP
// integer types
class WXDLLIMPEXP_BASE wxIntegerHash
wxIntegerHash& operator=(const wxIntegerHash&) { return *this; }
};
-#endif // !wxUSE_STL || !defined(HAVE_STL_HASH_MAP)
+#endif // !wxNEEDS_WX_HASH_MAP/wxNEEDS_WX_HASH_MAP
class WXDLLIMPEXP_BASE wxIntegerEqual
{
public:
wxPointerHash() { }
-#if wxUSE_STL && defined(HAVE_STL_HASH_MAP)
- size_t operator()( const void* k ) const { return (size_t)k; }
-#else
+#ifdef wxNEEDS_WX_HASH_MAP
wxUIntPtr operator()( const void* k ) const { return wxPtrToUInt(k); }
+#else
+ size_t operator()( const void* k ) const { return (size_t)k; }
#endif
wxPointerHash& operator=(const wxPointerHash&) { return *this; }
wxStringEqual& operator=(const wxStringEqual&) { return *this; }
};
-#if !wxUSE_STL || !defined(HAVE_STL_HASH_MAP)
+#ifdef wxNEEDS_WX_HASH_MAP
#define _WX_DECLARE_HASH_MAP( KEY_T, VALUE_T, HASH_T, KEY_EQ_T, CLASSNAME, CLASSEXP ) \
_WX_DECLARE_PAIR( KEY_T, VALUE_T, CLASSNAME##_wxImplementation_Pair, CLASSEXP ) \
} \
}
-#endif // !wxUSE_STL || !defined(HAVE_STL_HASH_MAP)
+#endif // wxNEEDS_WX_HASH_MAP
// these macros are to be used in the user code
#define WX_DECLARE_HASH_MAP( KEY_T, VALUE_T, HASH_T, KEY_EQ_T, CLASSNAME) \