diff options
author | kenton@google.com <kenton@google.com@630680e5-0e50-0410-840e-4b1c322b438d> | 2009-12-21 18:58:23 +0000 |
---|---|---|
committer | kenton@google.com <kenton@google.com@630680e5-0e50-0410-840e-4b1c322b438d> | 2009-12-21 18:58:23 +0000 |
commit | ee7e9420e3f76a9f6b68ac2581c48404783db07d (patch) | |
tree | a64e43ad45aa0e511227374ec2fc93a7ab0899bd /m4/stl_hash.m4 | |
parent | 8ee1474044c0618be2f53539ee7cc68560002b60 (diff) | |
download | protobuf-ee7e9420e3f76a9f6b68ac2581c48404783db07d.tar.gz protobuf-ee7e9420e3f76a9f6b68ac2581c48404783db07d.tar.bz2 protobuf-ee7e9420e3f76a9f6b68ac2581c48404783db07d.zip |
Use unordered_map when available. Changes to stl_hash.m4 provided by Oleg Smolsky.
Diffstat (limited to 'm4/stl_hash.m4')
-rw-r--r-- | m4/stl_hash.m4 | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/m4/stl_hash.m4 b/m4/stl_hash.m4 index 912b954e..84765a28 100644 --- a/m4/stl_hash.m4 +++ b/m4/stl_hash.m4 @@ -14,28 +14,39 @@ AC_DEFUN([AC_CXX_STL_HASH], [AC_MSG_CHECKING(the location of hash_map) AC_LANG_SAVE AC_LANG_CPLUSPLUS - ac_cv_cxx_hash_map="" - for location in ext/hash_map hash_map; do - for namespace in __gnu_cxx "" std stdext; do - if test -z "$ac_cv_cxx_hash_map"; then - AC_TRY_COMPILE([#include <$location>], - [${namespace}::hash_map<int, int> t], - [ac_cv_cxx_hash_map="<$location>"; - ac_cv_cxx_hash_namespace="$namespace";]) - fi + ac_cv_cxx_hash_map_header="" + ac_cv_cxx_hash_map_class="" + for location in [tr1/unordered_map ext/hash_map hash_map]; do + for namespace in [std::tr1 __gnu_cxx "" std stdext]; do + for name in [unordered_map hash_map]; do + + if test -z "$ac_cv_cxx_hash_map_header"; then + + AC_TRY_COMPILE([#include <$location>], + [${namespace}::$name<int, int> t], + [ac_cv_cxx_hash_map_header="<$location>"; + ac_cv_cxx_hash_namespace="$namespace"; + ac_cv_cxx_hash_map_class="$name";]) + fi + done done done - ac_cv_cxx_hash_set=`echo "$ac_cv_cxx_hash_map" | sed s/map/set/`; - if test -n "$ac_cv_cxx_hash_map"; then + ac_cv_cxx_hash_set_header=`echo "$ac_cv_cxx_hash_map_header" | sed s/map/set/`; + ac_cv_cxx_hash_set_class=`echo "$ac_cv_cxx_hash_map_class" | sed s/map/set/`; + if test -n "$ac_cv_cxx_hash_map_header"; then AC_DEFINE(HAVE_HASH_MAP, 1, [define if the compiler has hash_map]) AC_DEFINE(HAVE_HASH_SET, 1, [define if the compiler has hash_set]) - AC_DEFINE_UNQUOTED(HASH_MAP_H,$ac_cv_cxx_hash_map, + AC_DEFINE_UNQUOTED(HASH_MAP_H,$ac_cv_cxx_hash_map_header, [the location of <hash_map>]) - AC_DEFINE_UNQUOTED(HASH_SET_H,$ac_cv_cxx_hash_set, + AC_DEFINE_UNQUOTED(HASH_SET_H,$ac_cv_cxx_hash_set_header, [the location of <hash_set>]) + AC_DEFINE_UNQUOTED(HASH_MAP_CLASS,$ac_cv_cxx_hash_map_class, + [the name of <hash_set>]) + AC_DEFINE_UNQUOTED(HASH_SET_CLASS,$ac_cv_cxx_hash_set_class, + [the name of <hash_set>]) AC_DEFINE_UNQUOTED(HASH_NAMESPACE,$ac_cv_cxx_hash_namespace, [the namespace of hash_map/hash_set]) - AC_MSG_RESULT([$ac_cv_cxx_hash_map]) + AC_MSG_RESULT([$ac_cv_cxx_hash_map_header]) else AC_MSG_RESULT() AC_MSG_WARN([could not find an STL hash_map]) |