1 //===-- llvm/ADT/hash_map - "Portable" wrapper around hash_map --*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file provides a wrapper around the mysterious <hash_map> header file
11 // that seems to move around between GCC releases into and out of namespaces at
12 // will. #including this header will cause hash_map to be available in the
15 //===----------------------------------------------------------------------===//
17 #ifndef LLVM_ADT_HASH_MAP
18 #define LLVM_ADT_HASH_MAP
20 // Compiler Support Matrix
22 // Version Namespace Header File
24 // 3.0.4 std ext/hash_map
25 // 3.1 __gnu_cxx ext/hash_map
26 // HP aCC6 std stdex/rw/hashm*ap.h
29 #undef HAVE_GNU_EXT_HASH_MAP
30 #undef HAVE_STD_EXT_HASH_MAP
31 #undef HAVE_GLOBAL_HASH_MAP
32 #undef HAVE_RW_STDEX_HASH_MAP_H
34 #if HAVE_GNU_EXT_HASH_MAP
35 // This is for GCC-3.1+ which puts hash in ext/hash_map
36 # include <ext/hash_map>
37 # ifndef HASH_NAMESPACE
38 # define HASH_NAMESPACE __gnu_cxx
41 // GCC 3.0.x puts hash_map in <ext/hash_map> and in the std namespace.
42 #elif HAVE_STD_EXT_HASH_MAP
43 # include <ext/hash_map>
44 # ifndef HASH_NAMESPACE
45 # define HASH_NAMESPACE std
48 // Older compilers such as GCC before version 3.0 do not keep
49 // extensions in the `ext' directory, and ignore the `std' namespace.
50 #elif HAVE_GLOBAL_HASH_MAP
52 # ifndef HASH_NAMESPACE
53 # define HASH_NAMESPACE std
56 // HP aCC doesn't include an SGI-like hash_map. For this platform (or
57 // any others using Rogue Wave Software's Tools.h++ library), we wrap
58 // around them in std::
59 #elif HAVE_RW_STDEX_HASH_MAP_H
60 # include <rw/stdex/hashmap.h>
61 # include <rw/stdex/hashmmap.h>
62 # ifndef HASH_NAMESPACE
63 # define HASH_NAMESPACE std
66 // Give a warning if we couldn't find it, instead of (or in addition to)
67 // randomly doing something dumb.
69 # warning "Autoconfiguration failed to find the hash_map header file."
72 // we wrap Rogue Wave Tools.h++ rw_hashmap into something SGI-looking, here:
73 #ifdef HAVE_RW_STDEX_HASH_MAP_H
74 namespace HASH_NAMESPACE {
76 template <class DataType> struct hash {
77 unsigned int operator()(const unsigned int& x) const {
82 template <typename KeyType,
84 class _HashFcn = hash<KeyType>,
85 class _EqualKey = equal_to<KeyType>,
86 class _A = allocator <ValueType> >
87 class hash_map : public rw_hashmap<KeyType, ValueType, class _HashFcn, class _EqualKey, class _A> {
90 template <typename KeyType,
92 class _HashFcn = hash<KeyType>,
93 class _EqualKey = equal_to<KeyType>,
94 class _A = allocator <ValueType> >
95 class hash_multimap : public rw_hashmultimap<KeyType, ValueType, class _HashFcn, class _EqualKey, class _A> {
98 } // end HASH_NAMESPACE;
101 using HASH_NAMESPACE::hash_map;
102 using HASH_NAMESPACE::hash_multimap;
103 using HASH_NAMESPACE::hash;
105 // Include vector because ext/hash_map includes stl_vector.h and leaves
106 // out specializations like stl_bvector.h, causing link conflicts.
109 #include "llvm/ADT/HashExtras.h"