From 0cacbf30d294b61f8a001d01a6dfc300ce797132 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 30 Jul 2010 03:56:14 -0400 Subject: Fixed hash_map code to build on VS 2008 --- include/anope.h | 5 +++++ include/hashcomp.h | 27 ++++++++++++++++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/anope.h b/include/anope.h index 3749005ed..4cd8fc2b0 100644 --- a/include/anope.h +++ b/include/anope.h @@ -259,6 +259,11 @@ namespace Anope */ struct hash { + /* VS 2008 specific code */ + enum { bucket_size = 4, min_buckets = 8 }; + bool operator()(const string &s1, const string &s2) const; + /* End of 2008 specific code */ + /** Hash an Anope::string for unordered_map * @param s The string * @return A hash value for the string diff --git a/include/hashcomp.h b/include/hashcomp.h index 77e3c0439..9dc992fd0 100644 --- a/include/hashcomp.h +++ b/include/hashcomp.h @@ -45,9 +45,20 @@ namespace Anope # define unordered_map hash_map # endif #else +# if _MSV_VER >= 1600 /* MSVC 2010+ has tr1. Though MSVC and GCC use different includes! */ -# include -# define unordered_map_namespace std::tr1 +# include +# define unordered_map_namespace std::tr1 +# else +# include +# define unordered_map_namespace +template +class unordered_map : public stdext::hash_map +{ + public: + unordered_map() : hash_map() { } +}; +# endif #endif /******************************************************* @@ -161,6 +172,11 @@ namespace irc */ struct hash { + /* VS 2008 specific code */ + enum { bucket_size = 4, min_buckets = 8 }; + bool operator()(const Anope::string &s1, const Anope::string &s2) const; + /* End VS 2008 specific code */ + /** Hash an irc::string for unordered_map * @param s The string * @return A hash value for the string @@ -227,6 +243,11 @@ namespace ci */ struct hash { + /* VS 2008 specific code */ + enum { bucket_size = 4, min_buckets = 8 }; + bool operator()(const Anope::string &s1, const Anope::string &s2) const; + /* End VS 2008 specific code */ + /** Hash a ci::string for unordered_map * @param s The string * @return A hash value for the string @@ -271,7 +292,7 @@ namespace std */ template<> class CoreExport less { - public: + public: /** Compare two Anope::strings as ci::strings and find which one is less * @param s1 The first string * @param s2 The second string -- cgit