1 //===-- HashExtras.h - Useful functions for STL hash containers --*- C++ -*--=//
3 // This file contains some templates that are useful if you are working with the
4 // STL Hashed containers.
6 // No library is required when using these functinons.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_SUPPORT_HASHEXTRAS_H
11 #define LLVM_SUPPORT_HASHEXTRAS_H
14 #include "Support/hash_map"
16 // Cannot specialize hash template from outside of the std namespace.
17 namespace HASH_NAMESPACE {
19 template <> struct hash<std::string> {
20 size_t operator()(std::string const &str) const {
21 return hash<char const *>()(str.c_str());
25 // Provide a hash function for arbitrary pointers...
26 template <class T> struct hash<T *> {
27 inline size_t operator()(const T *Val) const { return (size_t)Val; }
30 } // End namespace std