10
10
# prints messages itself, so we have to do the message-printing ourselves
11
11
# via AC_MSG_CHECKING + AC_MSG_RESULT. (TODO(csilvers): can we cache?)
13
AC_DEFUN([PANDORA_CXX_STL_HASH],
13
AC_DEFUN([AC_CXX_STL_HASH],
14
14
[AC_MSG_CHECKING(the location of hash_map)
15
save_CXXFLAGS="${CXXFLAGS}"
16
CXXFLAGS="${AM_CXXFLAGS} ${CXXFLAGS}"
18
16
ac_cv_cxx_hash_map=""
19
for location in "" "ext/" "tr1/" ; do
17
for location in ext/hash_map boost/hash_map hash_map; do
20
18
for namespace in __gnu_cxx "" std stdext; do
21
for classprefix in unordered hash; do
22
if test -z "$ac_cv_cxx_hash_map"; then
24
[AC_LANG_PROGRAM([[#include <${location}${classprefix}_map>]],
25
[[${namespace}::${classprefix}_map<int, int> t]])],
26
[ac_cv_cxx_hash_map="<${location}${classprefix}_map>";
27
ac_cv_cxx_hash_set="<${location}${classprefix}_set>";
28
ac_cv_cxx_hash_namespace="$namespace";
29
ac_cv_cxx_hash_map_class="${classprefix}_map";
30
ac_cv_cxx_hash_set_class="${classprefix}_set"])
19
if test -z "$ac_cv_cxx_hash_map"; then
22
[[#include <$location>]],
23
[[${namespace}::hash_map<int, int> t]])],
24
[ac_cv_cxx_hash_map="<$location>";
25
ac_cv_cxx_hash_namespace="$namespace";])
30
ac_cv_cxx_hash_set=`echo "$ac_cv_cxx_hash_map" | sed s/map/set/`;
37
31
if test -n "$ac_cv_cxx_hash_map"; then
38
32
AC_DEFINE(HAVE_HASH_MAP, 1, [define if the compiler has hash_map])
39
33
AC_DEFINE(HAVE_HASH_SET, 1, [define if the compiler has hash_set])
43
37
[the location of <hash_set>])
44
38
AC_DEFINE_UNQUOTED(HASH_NAMESPACE,$ac_cv_cxx_hash_namespace,
45
39
[the namespace of hash_map/hash_set])
46
AC_DEFINE_UNQUOTED(HASH_MAP_CLASS,$ac_cv_cxx_hash_map_class,
47
[the classname of hash_map])
48
AC_DEFINE_UNQUOTED(HASH_SET_CLASS,$ac_cv_cxx_hash_set_class,
49
[the classname of hash_set])
50
40
AC_MSG_RESULT([$ac_cv_cxx_hash_map])
53
43
AC_MSG_WARN([could not find an STL hash_map])
56
[whether hash_map has rehash method],
57
[ac_cv_hash_map_has_rehash],
61
using namespace HASH_NAMESPACE;
63
HASH_MAP_CLASS<int, int> test_hash;
64
test_hash.rehash(100);
66
[ac_cv_hash_map_has_rehash=yes],
67
[ac_cv_hash_map_has_rehash=no])])
68
AS_IF([test $ac_cv_hash_map_has_rehash = yes],[
69
AC_DEFINE(HASH_MAP_HAS_REHASH, 1, [if hash_map<> hash rehash method])
72
[whether hash_map has resize method],
73
[ac_cv_hash_map_has_resize],
77
using namespace HASH_NAMESPACE;
79
HASH_MAP_CLASS<int, int> test_hash;
80
test_hash.resize(100);
82
[ac_cv_hash_map_has_resize=yes],
83
[ac_cv_hash_map_has_resize=no])])
84
AS_IF([test $ac_cv_hash_map_has_resize = yes],[
85
AC_DEFINE(HASH_MAP_HAS_RESIZE, 1, [if hash_map<> hash resize method])
88
[whether to redefine hash<string>],
89
[ac_cv_redefine_hash_string],
94
using namespace HASH_NAMESPACE;
97
string teststr("test");
98
HASH_SET_CLASS<string> test_hash;
99
HASH_SET_CLASS<string>::iterator iter= test_hash.find(teststr);
100
if (iter != test_hash.end())
103
[ac_cv_redefine_hash_string=no],
104
[ac_cv_redefine_hash_string=yes])])
105
AS_IF([test $ac_cv_redefine_hash_string = yes],[
106
AC_DEFINE(REDEFINE_HASH_STRING, 1, [if hash<string> needs to be defined])
108
CXXFLAGS="${save_CXXFLAGS}"