1 //===-- llvm/ADT/hash_set - "Portable" wrapper around hash_set --*- 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 //===----------------------------------------------------------------------===//
11 // This file provides a wrapper around the mysterious <hash_set> header file
12 // that seems to move around between GCC releases into and out of namespaces at
13 // will. #including this header will cause hash_set to be available in the
16 //===----------------------------------------------------------------------===//
18 #ifndef LLVM_ADT_HASH_SET
19 #define LLVM_ADT_HASH_SET
21 // Compiler Support Matrix
23 // Version Namespace Header File
25 // 3.0.4 std ext/hash_set
26 // 3.1 __gnu_cxx ext/hash_set
27 // HP aCC6 std stdex/rw/hashset.h
30 #undef HAVE_GNU_EXT_HASH_SET
31 #undef HAVE_STD_EXT_HASH_SET
32 #undef HAVE_GLOBAL_HASH_SET
33 #undef HAVE_RW_STDEX_HASH_SET_H
35 // GCC versions 3.1 and later put hash_set in <ext/hash_set> and in
36 // the __gnu_cxx namespace.
37 #if HAVE_GNU_EXT_HASH_SET
38 # include <ext/hash_set>
39 # ifndef HASH_NAMESPACE
40 # define HASH_NAMESPACE __gnu_cxx
43 // GCC 3.0.x puts hash_set in <ext/hash_set> and in the std namespace.
44 #elif HAVE_STD_EXT_HASH_SET
45 # include <ext/hash_set>
46 # ifndef HASH_NAMESPACE
47 # define HASH_NAMESPACE std
50 // Older compilers such as GCC before version 3.0 do not keep
51 // extensions in the `ext' directory, and ignore the `std' namespace.
52 #elif HAVE_GLOBAL_HASH_SET
54 # ifndef HASH_NAMESPACE
55 # define HASH_NAMESPACE std
58 // HP aCC doesn't include an SGI-like hash_set. For this platform (or
59 // any others using Rogue Wave Software's Tools.h++ library), we wrap
60 // around them in std::
61 #elif HAVE_RW_STDEX_HASH_SET_H
62 # include <rw/stdex/hashset.h>
63 # ifndef HASH_NAMESPACE
64 # define HASH_NAMESPACE std
67 // Give a warning if we couldn't find it, instead of (or in addition to)
68 // randomly doing something dumb.
70 # warning "Autoconfiguration failed to find the hash_set header file."
73 // we wrap Rogue Wave Tools.h++ rw_hashset into something SGI-looking, here:
74 #ifdef HAVE_RW_STDEX_HASH_SET_H
75 namespace HASH_NAMESPACE {
78 template <class DataType> struct hash {
79 unsigned int operator()(const unsigned int& x) const {
85 template <typename ValueType,
86 class _HashFcn = hash<ValueType>,
87 class _EqualKey = equal_to<ValueType>,
88 class _A = allocator <ValueType> >
89 class hash_set : public rw_hashset<ValueType, class _HashFcn, class _EqualKey, class _A> {
92 } // end HASH_NAMESPACE;
95 using HASH_NAMESPACE::hash_set;
96 using HASH_NAMESPACE::hash;
98 // Include vector because ext/hash_set includes stl_vector.h and leaves
99 // out specializations like stl_bvector.h, causing link conflicts.
102 #include "llvm/ADT/HashExtras.h"