# HG changeset patch # User Michael Goffioul # Date 1319111491 -3600 # Node ID 478efc95cb7a4d93756b6a67b7cd0390b08db9d0 # Parent 5a2734f26dbc50f8164d1b4dc861c7c28d16340c Test unordered_map header location and namespace. * configure.ac: Add tests for and . Add test to determine whether std::tr1 namespace is required for unordered_map. * rand.cc: Use tests result. diff -r 5a2734f26dbc -r 478efc95cb7a configure.ac --- 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 , but still have to check whether + ### tr1 namespace is required (like MSVC, for instance). + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([ + #include + ], [ + 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 diff -r 5a2734f26dbc -r 478efc95cb7a src/DLD-FUNCTIONS/rand.cc --- a/src/DLD-FUNCTIONS/rand.cc Wed Oct 19 17:15:42 2011 +0100 +++ b/src/DLD-FUNCTIONS/rand.cc Thu Oct 20 12:51:31 2011 +0100 @@ -26,7 +26,11 @@ #endif #include +#if defined (HAVE_UNORDERED_MAP) +#include +#elif defined (HAVE_TR1_UNORDERED_MAP) #include +#endif #include #include "f77-fcn.h" @@ -42,6 +46,12 @@ #include "utils.h" #include "ov-re-mat.h" +#ifdef USE_UNORDERED_MAP_WITH_TR1 +using namespace std::tr1; +#else +using namespace std; +#endif + /* %!shared __random_statistical_tests__ %! % Flag whether the statistical tests should be run in "make check" or not @@ -1066,8 +1076,7 @@ if (short_shuffle) { - std::tr1::unordered_map map (m); + unordered_map map (m); // Perform the Knuth shuffle only keeping track of moved // entries in the map