1 # We check two things: where the include file is for hash_map, and
2 # what namespace hash_map lives in within that include file. We
3 # include AC_COMPILE_IFELSE for all the combinations we've seen in the
4 # wild. We define one of HAVE_HASH_MAP or HAVE_EXT_HASH_MAP depending
5 # on location, and HASH_NAMESPACE to be the namespace hash_map is
8 # Ideally we'd use AC_CACHE_CHECK, but that only lets us store one value
9 # at a time, and we need to store two (filename and namespace).
10 # prints messages itself, so we have to do the message-printing ourselves
11 # via AC_MSG_CHECKING + AC_MSG_RESULT. (TODO(csilvers): can we cache?)
13 AC_DEFUN([PANDORA_CXX_STL_HASH],
14 [AC_MSG_CHECKING(the location of hash_map)
17 for location in "" "ext/" "tr1/" ; do
18 for namespace in __gnu_cxx "" std stdext; do
19 for classprefix in unordered hash; do
20 if test -z "$ac_cv_cxx_hash_map"; then
22 [AC_LANG_PROGRAM([[#include <${location}${classprefix}_map>]],
23 [[${namespace}::${classprefix}_map<int, int> t]])],
24 [ac_cv_cxx_hash_map="<${location}${classprefix}_map>";
25 ac_cv_cxx_hash_set="<${location}${classprefix}_set>";
26 ac_cv_cxx_hash_namespace="$namespace";
27 ac_cv_cxx_hash_map_class="${classprefix}_map";
28 ac_cv_cxx_hash_set_class="${classprefix}_set"])
35 if test -n "$ac_cv_cxx_hash_map"; then
36 AC_DEFINE(HAVE_HASH_MAP, 1, [define if the compiler has hash_map])
37 AC_DEFINE(HAVE_HASH_SET, 1, [define if the compiler has hash_set])
38 AC_DEFINE_UNQUOTED(HASH_MAP_H,$ac_cv_cxx_hash_map,
39 [the location of <hash_map>])
40 AC_DEFINE_UNQUOTED(HASH_SET_H,$ac_cv_cxx_hash_set,
41 [the location of <hash_set>])
42 AC_DEFINE_UNQUOTED(HASH_NAMESPACE,$ac_cv_cxx_hash_namespace,
43 [the namespace of hash_map/hash_set])
44 AC_DEFINE_UNQUOTED(HASH_MAP_CLASS,$ac_cv_cxx_hash_map_class,
45 [the classname of hash_map])
46 AC_DEFINE_UNQUOTED(HASH_SET_CLASS,$ac_cv_cxx_hash_set_class,
47 [the classname of hash_set])
48 AC_MSG_RESULT([$ac_cv_cxx_hash_map])
51 AC_MSG_WARN([could not find an STL hash_map])
54 [whether hash_map has rehash method],
55 [ac_cv_hash_map_has_rehash],
59 using namespace HASH_NAMESPACE;
61 HASH_MAP_CLASS<int, int> test_hash;
62 test_hash.rehash(100);
64 [ac_cv_hash_map_has_rehash=yes],
65 [ac_cv_hash_map_has_rehash=no])])
66 AS_IF([test $ac_cv_hash_map_has_rehash = yes],[
67 AC_DEFINE(HASH_MAP_HAS_REHASH, 1, [if hash_map<> hash rehash method])
70 [whether hash_map has resize method],
71 [ac_cv_hash_map_has_resize],
75 using namespace HASH_NAMESPACE;
77 HASH_MAP_CLASS<int, int> test_hash;
78 test_hash.resize(100);
80 [ac_cv_hash_map_has_resize=yes],
81 [ac_cv_hash_map_has_resize=no])])
82 AS_IF([test $ac_cv_hash_map_has_resize = yes],[
83 AC_DEFINE(HASH_MAP_HAS_RESIZE, 1, [if hash_map<> hash resize method])
86 [whether to redefine hash<string>],
87 [ac_cv_redefine_hash_string],
92 using namespace HASH_NAMESPACE;
95 string teststr("test");
96 HASH_SET_CLASS<string> test_hash;
97 HASH_SET_CLASS<string>::iterator iter= test_hash.find(teststr);
98 if (iter != test_hash.end())
101 [ac_cv_redefine_hash_string=no],
102 [ac_cv_redefine_hash_string=yes])])
103 AS_IF([test $ac_cv_redefine_hash_string = yes],[
104 AC_DEFINE(REDEFINE_HASH_STRING, 1, [if hash<string> needs to be defined])