Commit c568b4d3 authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz
Browse files

hash.hh: Remove conditional code.

* m4/stl.m4: Delete.
* configure.ac: Do not check for unordered_map and friends.
* src/misc/hash.hh: Remove all conditional code.
parent f3874e05
......@@ -118,10 +118,6 @@ AC_CACHE_CHECK([whether $CXX $CXXFLAGS supports C++11 features],
test "x$ax_cv_cxx_compile_cxx11" = xyes ||
AC_ERROR([unable to compile C++11 with this compiler])
AC_HEADER_UNORDERED_MAP
AC_HEADER_TR1_UNORDERED_MAP
AC_HEADER_EXT_HASH_MAP
AX_CHECK_BUDDY
AX_CHECK_GSPNLIB
AX_CHECK_BOOST([1.34], [103400])
......
AC_DEFUN([AC_HEADER_EXT_HASH_MAP], [
AC_CACHE_CHECK([for ext/hash_map],
[ac_cv_cxx_ext_hash_map],
[AC_LANG_SAVE
AC_LANG_CPLUSPLUS
ac_save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -Werror"
AC_TRY_COMPILE([#include <ext/hash_map>], [using __gnu_cxx::hash_map;],
[ac_cv_cxx_ext_hash_map=yes], [ac_cv_cxx_ext_hash_map=no])
CXXFLAGS="$ac_save_CXXFLAGS"
AC_LANG_RESTORE
])
if test "$ac_cv_cxx_ext_hash_map" = yes; then
AC_DEFINE([HAVE_EXT_HASH_MAP],, [Define if ext/hash_map is present.])
fi
])
AC_DEFUN([AC_HEADER_TR1_UNORDERED_MAP], [
AC_CACHE_CHECK([for tr1/unordered_map],
[ac_cv_cxx_tr1_unordered_map],
[AC_LANG_SAVE
AC_LANG_CPLUSPLUS
ac_save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -Werror"
# GCC 4.0.0 has tr1/unordered_map, but it fails to compile the following code
AC_TRY_COMPILE([#include <tr1/unordered_map>],
[using std::tr1::unordered_map;
const unordered_map<int, int> t;
return t.find(42) == t.end();],
[ac_cv_cxx_tr1_unordered_map=yes], [ac_cv_cxx_tr1_unordered_map=no])
CXXFLAGS="$ac_save_CXXFLAGS"
AC_LANG_RESTORE
])
if test "$ac_cv_cxx_tr1_unordered_map" = yes; then
AC_DEFINE([HAVE_TR1_UNORDERED_MAP],, [Define if tr1/unordered_map is present.])
fi
])
AC_DEFUN([AC_HEADER_UNORDERED_MAP], [
AC_CACHE_CHECK([for unordered_map],
[ac_cv_cxx_unordered_map],
[AC_LANG_SAVE
AC_LANG_CPLUSPLUS
ac_save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -Werror"
AC_TRY_COMPILE([#include <unordered_map>], [using std::unordered_map;],
[ac_cv_cxx_unordered_map=yes], [ac_cv_cxx_unordered_map=no])
CXXFLAGS="$ac_save_CXXFLAGS"
AC_LANG_RESTORE
])
if test "$ac_cv_cxx_unordered_map" = yes; then
AC_DEFINE([HAVE_UNORDERED_MAP],, [Define if unordered_map is present.])
fi
])
......@@ -28,49 +28,12 @@
# include "misc/hashfunc.hh"
# include "misc/_config.h"
#ifdef SPOT_HAVE_UNORDERED_MAP
# include <unordered_map>
# include <unordered_set>
namespace Sgi = std;
# define hash_map unordered_map
# define hash_multimap unordered_multimap
# define hash_set unordered_set
#else
#ifdef SPOT_HAVE_TR1_UNORDERED_MAP
# include <tr1/unordered_map>
# include <tr1/unordered_set>
namespace Sgi = std::tr1;
# define hash_map unordered_map
# define hash_multimap unordered_multimap
# define hash_set unordered_set
#else
#ifdef SPOT_HAVE_EXT_HASH_MAP
# include <ext/hash_map>
# include <ext/hash_set>
# if __GNUC__ == 3 && __GNUC_MINOR__ == 0
namespace Sgi = std; // GCC 3.0
# else
namespace Sgi = ::__gnu_cxx; // GCC 3.1 to 4.2
# endif
#else
# if defined(__GNUC__) && (__GNUC__ < 3)
# include <hash_map.h>
# include <hash_set.h>
namespace Sgi
{ // inherit globals
using ::hash_map;
using ::hash_multimap;
using ::hash_set;
using ::hash;
}
# else
# include <hash_map>
# include <hash_set>
namespace Sgi = std;
# endif
#endif
#endif
#endif
namespace spot
{
......@@ -97,29 +60,7 @@ namespace spot
/// \ingroup hash_funcs
/// \brief A hash function for strings.
/// @{
#if defined(SPOT_HAVE_UNORDERED_MAP) || defined(SPOT_HAVE_TR1_UNORDERED_MAP)
typedef Sgi::hash<std::string> string_hash;
#else // e.g. GCC < 4.3
struct string_hash:
public Sgi::hash<const char*>,
public std::unary_function<const std::string&, size_t>
{
// A default constructor is needed if the string_hash object is
// stored in a const member.
string_hash()
{
}
size_t operator()(const std::string& s) const
{
// We are living dangerously. Be sure to call operator()
// from the super-class, not this one.
return Sgi::hash<const char*>::operator()(s.c_str());
}
};
/// @}
#endif
/// \ingroup hash_funcs
/// \brief A hash function that returns identity
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment