blob: 6ea831e78f0d6fe77fca702dcd556a4be249263d [file] [log] [blame]
Chris Lattner57dbb3a2001-07-23 17:46:59 +00001//===-- HashExtras.h - Useful functions for STL hash containers --*- C++ -*--=//
2//
3// This file contains some templates that are useful if you are working with the
4// STL Hashed containers.
5//
6// No library is required when using these functinons.
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef LLVM_SUPPORT_HASHEXTRAS_H
11#define LLVM_SUPPORT_HASHEXTRAS_H
12
13#include <string>
14#include <hash_map>
15
16template <> struct hash<string> {
17 size_t operator()(string const &str) const {
18 return hash<char const *>()(str.c_str());
19 }
20};
21
Vikram S. Advebf2b7e82001-07-28 04:41:10 +000022// Provide a hash function for arbitrary pointers...
23template <class T> struct hash<T *> {
24 inline size_t operator()(const T *Val) const { return (size_t)Val; }
25};
26
Chris Lattner57dbb3a2001-07-23 17:46:59 +000027#endif