IMP  2.1.0
The Integrative Modeling Platform
base/hash.h
Go to the documentation of this file.
1 /**
2  * \file IMP/base/hash.h \brief IO support.
3  *
4  * Copyright 2007-2013 IMP Inventors. All rights reserved.
5  *
6  */
7 
8 #ifndef IMPBASE_HASH_H
9 #define IMPBASE_HASH_H
10 
11 #include <IMP/base/base_config.h>
12 
13 #ifdef __clang__
14 IMP_CLANG_PRAGMA(diagnostic push)
15 IMP_CLANG_PRAGMA(diagnostic ignored "-Wmismatched-tags")
16 #endif
17 #include <boost/functional/hash.hpp>
18 #include <boost/functional/hash/hash.hpp>
19 #ifdef __clang__
20 IMP_CLANG_PRAGMA(diagnostic pop)
21 #endif
22 
23 // evil hack to suppress warning on cluster
24 // the expected pragmas don't work
25 #ifdef __GNUC__
26 #undef __DEPRECATED
27 #endif
28 // this specializes some hash methods
29 #include <boost/graph/adjacency_list.hpp>
30 #ifdef __GNUC__
31 #define __DEPRECATED
32 #endif
33 
34 IMPBASE_BEGIN_NAMESPACE
35 template <class T>
36 inline std::size_t hash_value(const T &t) {
37  return t.__hash__();
38 }
39 inline std::size_t hash_value(double d) { return boost::hash_value(d); }
40 inline std::size_t hash_value(int d) { return boost::hash_value(d); }
41 inline std::size_t hash_value(bool d) { return boost::hash_value(d); }
42 inline std::size_t hash_value(const std::string &d) {
43  return boost::hash_value(d);
44 }
45 
46 // for RMF
47 template <class T>
48 inline std::size_t hash_value(const std::vector<T> &t) {
49  return boost::hash_range(t.begin(), t.end());
50 }
51 IMPBASE_END_NAMESPACE
52 
53 #endif /* IMPBASE_HASH_H */