diff configure.ac @ 13727:478efc95cb7a

Test unordered_map header location and namespace. * configure.ac: Add tests for <unordered_map> and <tr1/unordered_map>. Add test to determine whether std::tr1 namespace is required for unordered_map. * rand.cc: Use tests result.
author Michael Goffioul <michael.goffioul@gmail.com>
date Thu, 20 Oct 2011 12:51:31 +0100
parents 571557ddabb9
children 510237e67c2b 3c3b74677fa0
line wrap: on
line diff
--- a/configure.ac	Wed Oct 19 17:15:42 2011 +0100
+++ b/configure.ac	Thu Oct 20 12:51:31 2011 +0100
@@ -1548,6 +1548,26 @@
 
 AC_LANG_PUSH(C++)
 AC_CHECK_HEADERS(sstream)
+AC_CHECK_HEADERS([unordered_map], [], [
+  AC_CHECK_HEADERS([tr1/unordered_map])])
+AC_MSG_CHECKING([whether unordered_map requires tr1 namespace])
+unordered_map_requires_tr1_namespace=no
+if test "$ac_cv_header_unordered_map" = "yes"; then
+  ### Have <unordered_map>, but still have to check whether
+  ### tr1 namespace is required (like MSVC, for instance).
+  AC_COMPILE_IFELSE([
+    AC_LANG_PROGRAM([
+      #include <unordered_map>
+    ], [
+      std::unordered_map m;
+    ])], [], [unordered_map_requires_tr1_namespace=yes])
+elif test "$ac_cv_header_tr1_unordered_map" = "yes"; then
+  unordered_map_requires_tr1_namespace=yes
+fi
+if test "$unordered_map_requires_tr1_namespace" = "yes"; then
+  AC_DEFINE(USE_UNORDERED_MAP_WITH_TR1, 1, [Defines whether unordered_map requires the use of tr1 namespace.])
+fi
+AC_MSG_RESULT([$unordered_map_requires_tr1_namespace])
 AC_LANG_POP(C++)
 
 have_termios_h=no