From 53fe5bb2f9a2f4956ad63ac42df2047a8b8705ec Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Tue, 14 Jan 2014 19:05:56 +0000 Subject: fix warnings on compilers that provide unordered_set (bzr r12929) --- configure.ac | 22 ++++++++++++++++++++-- src/util/unordered-containers.h | 18 +++++++++++++++++- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index e39c54db7..dbffcfbde 100644 --- a/configure.ac +++ b/configure.ac @@ -148,19 +148,37 @@ if test "$GCC" = "yes"; then fi # Detect a working version of unordered containers. +# First try looking for native support (C++11 feature) +AC_MSG_CHECKING([native support for unordered_set]) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], +[[ + std::unordered_set i, j; + i = j; +]])], +[native_unordered_set_works=yes], [native_unordered_set_works=no]) + +if test "x$native_unordered_set_works" = "xyes"; then + AC_MSG_RESULT([ok]) + AC_DEFINE(HAVE_NATIVE_UNORDERED_SET, 1, [Has working native unordered_set]) +else + AC_MSG_RESULT([not working]) +fi + AC_MSG_CHECKING([TR1 unordered_set usability]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ std::tr1::unordered_set i, j; i = j; ]])], -[unordered_set_works=yes], [unordered_set_works=no]) -if test "x$unordered_set_works" = "xyes"; then +[tr1_unordered_set_works=yes], [tr1_unordered_set_works=no]) + +if test "x$tr1_unordered_set_works" = "xyes"; then AC_MSG_RESULT([ok]) AC_DEFINE(HAVE_TR1_UNORDERED_SET, 1, [Has working standard TR1 unordered_set]) else AC_MSG_RESULT([not working]) fi + AC_CHECK_HEADER([boost/unordered_set.hpp], [AC_DEFINE(HAVE_BOOST_UNORDERED_SET, 1, [Boost unordered_set (Boost >= 1.36)])], []) AC_CHECK_HEADER([ext/hash_set], [AC_DEFINE(HAVE_EXT_HASH_SET, 1, [Legacy GNU ext/hash_set])], []) diff --git a/src/util/unordered-containers.h b/src/util/unordered-containers.h index 70d36c4dc..98c2fa3c9 100644 --- a/src/util/unordered-containers.h +++ b/src/util/unordered-containers.h @@ -19,8 +19,24 @@ #include #ifndef DOXYGEN_SHOULD_SKIP_THIS -#if defined(HAVE_TR1_UNORDERED_SET) +#if defined(HAVE_NATIVE_UNORDERED_SET) +# include +# include +# define INK_UNORDERED_SET std::unordered_set +# define INK_UNORDERED_MAP std::unordered_map +# define INK_HASH std::hash + +namespace std { +template <> +struct hash : public std::unary_function { + std::size_t operator()(Glib::ustring const &s) const { + return hash()(s.raw()); + } +}; +} // namespace std + +#elif defined(HAVE_TR1_UNORDERED_SET) # include # include # define INK_UNORDERED_SET std::tr1::unordered_set -- cgit v1.2.3