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
28 // MS VC++ stdext hash_set
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 // Support Microsoft VC++.
68 #elif defined(_MSC_VER)
70 # ifndef HASH_NAMESPACE
71 # define HASH_NAMESPACE stdext
74 // Give a warning if we couldn't find it, instead of (or in addition to)
75 // randomly doing something dumb.
77 # warning "Autoconfiguration failed to find the hash_set header file."
80 // we wrap Rogue Wave Tools.h++ rw_hashset into something SGI-looking, here:
81 #ifdef HAVE_RW_STDEX_HASH_SET_H
82 namespace HASH_NAMESPACE {
85 template <class DataType> struct hash {
86 unsigned int operator()(const unsigned int& x) const {
92 template <typename ValueType,
93 class _HashFcn = hash<ValueType>,
94 class _EqualKey = equal_to<ValueType>,
95 class _A = allocator <ValueType> >
97 public rw_hashset<ValueType, class _HashFcn, class _EqualKey, class _A> {
100 } // end HASH_NAMESPACE;
103 using HASH_NAMESPACE::hash_set;
105 // Include vector because ext/hash_set includes stl_vector.h and leaves
106 // out specializations like stl_bvector.h, causing link conflicts.
109 #include "llvm/ADT/HashExtras.h"