OregonCore  revision 3611e8a-git
Your Favourite TBC server
UnorderedMap.h
Go to the documentation of this file.
1 /*
2  * This file is part of the OregonCore Project. See AUTHORS file for Copyright information
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by the
6  * Free Software Foundation; either version 2 of the License, or (at your
7  * option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef OREGON_UNORDERED_MAP_H
19 #define OREGON_UNORDERED_MAP_H
20 
21 #include "Platform/CompilerDefs.h"
22 #include "Platform/Define.h"
23 
24 #if COMPILER == COMPILER_INTEL
25 #include <ext/hash_map>
26 #elif COMPILER == COMPILER_GNU && (__clang__ || (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 3))
27 #include <unordered_map>
28 #elif COMPILER == COMPILER_GNU && __GNUC__ >= 3
29 #include <ext/hash_map>
30 #elif COMPILER == COMPILER_MICROSOFT && (_MSC_VER > 1500 || (_MSC_VER == 1500 && _HAS_TR1)) // VC9.0 and later
31 #include <unordered_map>
32 #else
33 #include <hash_map>
34 #endif
35 
36 #ifdef _STLPORT_VERSION
37 #define UNORDERED_MAP std::hash_map
38 using std::hash_map;
39 #elif COMPILER == COMPILER_MICROSOFT && _MSC_VER > 1500
40 #define UNORDERED_MAP std::unordered_map
41 #elif COMPILER == COMPILER_MICROSOFT && _MSC_VER == 1500 && _HAS_TR1
42 #define UNORDERED_MAP std::tr1::unordered_map
43 #elif COMPILER == COMPILER_MICROSOFT && _MSC_VER >= 1300
44 #define UNORDERED_MAP stdext::hash_map
45 using stdext::hash_map;
46 #elif COMPILER == COMPILER_INTEL
47 #define UNORDERED_MAP std::hash_map
48 using std::hash_map;
49 #elif COMPILER == COMPILER_GNU && (__clang__ || (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 3))
50 #define UNORDERED_MAP std::unordered_map
51 #elif COMPILER == COMPILER_GNU && __GNUC__ >= 3
52 #define UNORDERED_MAP __gnu_cxx::hash_map
53 
54 namespace __gnu_cxx
55 {
56 template<> struct hash<unsigned long long>
57 {
58  size_t operator()(const unsigned long long& __x) const
59  {
60  return (size_t)__x;
61  }
62 };
63 template<typename T> struct hash<T*>
64 {
65  size_t operator()(T* const& __x) const
66  {
67  return (size_t)__x;
68  }
69 };
70 template<> struct hash<std::string>
71 {
72  size_t operator()(const std::string& __x) const
73  {
74  return hash<const char*>()(__x.c_str());
75  }
76 };
77 
78 };
79 
80 #else
81 #define UNORDERED_MAP std::hash_map
82 using std::hash_map;
83 #endif
84 #endif
85