Remove configurey-fu to autodetect hash_map and hash_set now that they are
[oota-llvm.git] / include / llvm / ADT / HashExtras.h
1 //===-- llvm/ADT/HashExtras.h - Useful functions for STL hash ---*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file contains some templates that are useful if you are working with the
11 // STL Hashed containers.
12 //
13 // No library is required when using these functinons.
14 //
15 //===----------------------------------------------------------------------===//
16
17 #ifndef LLVM_ADT_HASHEXTRAS_H
18 #define LLVM_ADT_HASHEXTRAS_H
19
20 #include <string>
21
22 // Cannot specialize hash template from outside of the std namespace.
23 namespace HASH_NAMESPACE {
24
25 // Provide a hash function for arbitrary pointers...
26 template <class T> struct hash<T *> {
27   inline size_t operator()(const T *Val) const {
28     return reinterpret_cast<size_t>(Val);
29   }
30 };
31
32 template <> struct hash<std::string> {
33   size_t operator()(std::string const &str) const {
34     return hash<char const *>()(str.c_str());
35   }
36 };
37
38 }  // End namespace std
39
40 #endif