IMP  2.0.1
The Integrative Modeling Platform
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 // this specializes some hash methods
24 #include <boost/graph/adjacency_list.hpp>
25 
26 
27 IMPBASE_BEGIN_NAMESPACE
28 template <class T>
29 inline std::size_t hash_value(const T &t) {
30  return t.__hash__();
31 }
32 inline std::size_t hash_value(double d) {
33  return boost::hash_value(d);
34 }
35 inline std::size_t hash_value(int d) {
36  return boost::hash_value(d);
37 }
38 inline std::size_t hash_value(bool d) {
39  return boost::hash_value(d);
40 }
41 inline std::size_t hash_value(const std::string& d) {
42  return boost::hash_value(d);
43 }
44 
45 // for RMF
46 template <class T>
47 inline std::size_t hash_value(const std::vector<T> &t) {
48  return boost::hash_range(t.begin(), t.end());
49 }
50 IMPBASE_END_NAMESPACE
51 
52 #endif /* IMPBASE_HASH_H */