533b7574060c275ab3310ad3be606773c07b8010
[oota-llvm.git] / include / llvm / ADT / hash_set.in
1 //===-- llvm/ADT/hash_set - "Portable" wrapper around hash_set --*- C++ -*-===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
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.
7 // 
8 //===----------------------------------------------------------------------===//
9 // vim:ft=cpp
10 //
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
14 // global namespace.
15 //
16 //===----------------------------------------------------------------------===//
17
18 #ifndef LLVM_ADT_HASH_SET
19 #define LLVM_ADT_HASH_SET
20
21 // Compiler Support Matrix
22 //
23 // Version   Namespace   Header File
24 //  2.95.x       ::        hash_set
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 //
29
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
34
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
41 # endif
42
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
48 # endif
49
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
53 # include <hash_set>
54 # ifndef HASH_NAMESPACE
55 #  define HASH_NAMESPACE std
56 # endif
57
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
65 # endif
66
67 // Give a warning if we couldn't find it, instead of (or in addition to)
68 // randomly doing something dumb.
69 #else
70 # warning "Autoconfiguration failed to find the hash_set header file."
71 #endif
72
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 {
76
77 /*
78 template <class DataType> struct hash {
79     unsigned int operator()(const unsigned int& x) const {
80         return x;
81     }
82 };
83 */
84
85 template <typename ValueType,
86   class _HashFcn = hash<ValueType>,
87   class _EqualKey = equal_to<ValueType>,
88   class _A = allocator <ValueType> >
89 class hash_set : 
90   public rw_hashset<ValueType, class _HashFcn, class _EqualKey, class _A> {
91 };
92
93 } // end HASH_NAMESPACE;
94 #endif
95
96 using HASH_NAMESPACE::hash_set;
97 using HASH_NAMESPACE::hash;
98
99 // Include vector because ext/hash_set includes stl_vector.h and leaves
100 // out specializations like stl_bvector.h, causing link conflicts.
101 #include <vector>
102
103 #include "llvm/ADT/HashExtras.h"
104
105 #endif