fix src/util/hash.h to specialize GNU's hash template for <uint64_t> on platforms...
[cvc5.git] / src / util / hash.h
1 /********************* */
2 /*! \file hash.h
3 ** \verbatim
4 ** Original author: cconway
5 ** Major contributors: mdeters
6 ** Minor contributors (to current version): taking
7 ** This file is part of the CVC4 prototype.
8 ** Copyright (c) 2009, 2010, 2011 The Analysis of Computer Systems Group (ACSys)
9 ** Courant Institute of Mathematical Sciences
10 ** New York University
11 ** See the file COPYING in the top-level source directory for licensing
12 ** information.\endverbatim
13 **
14 ** \brief [[ Add one-line brief description here ]]
15 **
16 ** [[ Add lengthier description here ]]
17 ** \todo document this file
18 **/
19
20 #include "cvc4_public.h"
21
22 #ifndef __CVC4__HASH_H
23 #define __CVC4__HASH_H
24
25 // in case it's not been declared as a namespace yet
26 namespace __gnu_cxx {}
27
28 #include <ext/hash_map>
29
30 namespace __gnu_cxx {
31
32 #ifdef CVC4_NEED_HASH_UINT64_T
33 // on some versions and architectures of GNU C++, we need a
34 // specialization of hash for 64-bit values
35 template <>
36 struct hash<uint64_t> {
37 size_t operator()(uint64_t v) const {
38 return v;
39 }
40 };/* struct hash<uint64_t> */
41 #endif /* CVC4_NEED_HASH_UINT64_T */
42
43 }/* __gnu_cxx namespace */
44
45 // hackish: treat hash stuff as if it were in std namespace
46 namespace std { using namespace __gnu_cxx; }
47
48 namespace CVC4 {
49
50 struct StringHashFunction {
51 size_t operator()(const std::string& str) const {
52 return std::hash<const char*>()(str.c_str());
53 }
54 };/* struct StringHashFunction */
55
56 struct StringHashStrategy {
57 static size_t hash(const std::string& str) {
58 return std::hash<const char*>()(str.c_str());
59 }
60 };/* struct StringHashStrategy */
61
62 }/* CVC4 namespace */
63
64 #endif /* __CVC4__HASH_H */