summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Valavanis <valavanisalex@gmail.com>2014-01-14 19:05:56 +0000
committerAlex Valavanis <valavanisalex@gmail.com>2014-01-14 19:05:56 +0000
commit53fe5bb2f9a2f4956ad63ac42df2047a8b8705ec (patch)
tree8edda195793e1b56711ad617c90667ba1a657f62
parentFix bzr revision number in version string (LP #1071923) (diff)
downloadinkscape-53fe5bb2f9a2f4956ad63ac42df2047a8b8705ec.tar.gz
inkscape-53fe5bb2f9a2f4956ad63ac42df2047a8b8705ec.zip
fix warnings on compilers that provide unordered_set
(bzr r12929)
-rw-r--r--configure.ac22
-rw-r--r--src/util/unordered-containers.h18
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 <unordered_set>]],
+[[
+ std::unordered_set<int> 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 <tr1/unordered_set>]],
[[
std::tr1::unordered_set<int> 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 <glibmm/ustring.h>
#ifndef DOXYGEN_SHOULD_SKIP_THIS
-#if defined(HAVE_TR1_UNORDERED_SET)
+#if defined(HAVE_NATIVE_UNORDERED_SET)
+# include <unordered_set>
+# include <unordered_map>
+# define INK_UNORDERED_SET std::unordered_set
+# define INK_UNORDERED_MAP std::unordered_map
+# define INK_HASH std::hash
+
+namespace std {
+template <>
+struct hash<Glib::ustring> : public std::unary_function<Glib::ustring, std::size_t> {
+ std::size_t operator()(Glib::ustring const &s) const {
+ return hash<std::string>()(s.raw());
+ }
+};
+} // namespace std
+
+#elif defined(HAVE_TR1_UNORDERED_SET)
# include <tr1/unordered_set>
# include <tr1/unordered_map>
# define INK_UNORDERED_SET std::tr1::unordered_set