Adonthell
0.4
str_hash.h
Go to the documentation of this file.
1
/*
2
(C) Copyright 2001 Alexandre Courbot <alexandrecourbot@linuxgames.com>
3
(C) Copyright 2004/2016 Kai Sterker <kai.sterker@gmail.com>
4
Part of the Adonthell Project <http://adonthell.nongnu.org>
5
6
Adonthell is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2 of the License, or
9
(at your option) any later version.
10
11
Adonthell is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
15
16
You should have received a copy of the GNU General Public License
17
along with Adonthell. If not, see <http://www.gnu.org/licenses/>.
18
*/
19
20
/**
21
* @file str_hash.h
22
* @author Alexandre Courbot <alexandrecourbot@linuxgames.com>
23
* @author Kai Sterker <kai.sterker@gmail.com>
24
*
25
* @brief Declares the hash<string> type, to be able to declare
26
* hash_maps with strings as keys.
27
*/
28
29
#ifndef STR_HASH_H
30
#define STR_HASH_H
31
32
#ifdef __clang__
33
#if MAC_OS_X_VERSION_MIN_REQUIRED > 1060
34
#include <unordered_map>
35
#include <unordered_set>
36
37
#define hash_map unordered_map
38
#define hash_set unordered_set
39
#else
40
#include <tr1/unordered_map>
41
#include <tr1/unordered_set>
42
43
#define hash_map tr1::unordered_map
44
#define hash_set tr1::unordered_set
45
#endif
46
47
#else
48
49
// gcc >= 4.4
50
#if __GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 4
51
#include <tr1/unordered_map>
52
#include <tr1/unordered_set>
53
54
#define hash_map tr1::unordered_map
55
#define hash_set tr1::unordered_set
56
57
#else
58
// gcc < 4.4
59
#if __GNUG__ > 2
60
#include <ext/hash_map>
61
#include <ext/hash_set>
62
#else
63
#include <hash_map>
64
#include <hash_set>
65
#endif
66
#include <string>
67
68
#if __GNUG__ > 2
69
namespace
__gnu_cxx
70
#else
71
namespace
std
72
#endif
73
{
74
/**
75
* Hash function for strings.
76
*/
77
template
<>
struct
hash<
std
::string>
78
{
79
size_t
operator() (
const
std::string & __s)
const
80
{
81
return
__stl_hash_string (__s.c_str());
82
}
83
};
84
}
85
86
#if __GNUG__ > 2
87
namespace
std
{
using namespace
__gnu_cxx; }
88
#endif
89
#endif
90
#endif // CLANG
91
92
#endif // STR_HASH_H
std
Definition:
str_hash.h:71
src
str_hash.h
Generated by
1.8.14