diff --git a/dune/common/shared_ptr.hh b/dune/common/shared_ptr.hh index e3c0780c764dd011fa330dada8c8f84f025b3964..185efc4db061c3bb58a2069417c840ff36f28e32 100644 --- a/dune/common/shared_ptr.hh +++ b/dune/common/shared_ptr.hh @@ -5,15 +5,10 @@ #ifndef DUNE_SHARED_PTR_HH #define DUNE_SHARED_PTR_HH - -#if defined HAVE_MEMORY -# include <memory> -#endif -#if defined HAVE_TR1_MEMORY -# include <tr1/memory> +#if defined SHARED_PTR_HEADER +# include SHARED_PTR_HEADER #endif #if defined HAVE_BOOST_SHARED_PTR_HPP -# include <boost/shared_ptr.hpp> #if defined HAVE_BOOST_MAKE_SHARED_HPP # include <boost/make_shared.hpp> #endif diff --git a/m4/shared_ptr.m4 b/m4/shared_ptr.m4 index 2cca28414ef42d373a8bbd0c0e2ead55a7e9beb4..ab9c75cc990d81ad9fc73fa22e94e1036ac56942 100644 --- a/m4/shared_ptr.m4 +++ b/m4/shared_ptr.m4 @@ -13,7 +13,9 @@ dnl GCC 4.2: namespace: tr1:: #include <tr1/memory> dnl GCC 4.2: namespace: boost:: #include <boost/shared_ptr.hpp> dnl dnl We define one of HAVE_HAVE_TR1_SHARED_PTR or HAVE_BOOST_SHARED_PTR -dnl depending on location, and SHARED_PTR_NAMESPACE to be the namespace in +dnl depending on location, SHARED_PTR_HEADER to be the header with enclosing +dnl brackety braces in which shared_ptr is defined and SHARED_PTR_NAMESPACE to +dnl be the namespace in dnl which shared_ptr is defined. dnl @@ -30,15 +32,6 @@ dnl AC_REQUIRE([PANDORA_CHECK_CXX_STANDARD]) do AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[ -#if defined(HAVE_MEMORY) -# include <memory> -#endif -#if defined(HAVE_TR1_MEMORY) -# include <tr1/memory> -#endif -#if defined(HAVE_BOOST_SHARED_PTR_HPP) -# include <boost/shared_ptr.hpp> -#endif #include <string> using $namespace::shared_ptr; @@ -48,8 +41,33 @@ shared_ptr<string> test_ptr(new string("test string")); ]])], [ ac_cv_shared_ptr_namespace="${namespace}" + ac_cv_shared_ptr_header=missing break - ],[ac_cv_shared_ptr_namespace=missing]) + ],[ + ac_cv_shared_ptr_namespace=missing + ac_cv_shared_ptr_header=missing + ]) + for header in memory tr1/memory boost/shared_ptr.hpp; do + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[ +# include <$header> +#include <string> + +using $namespace::shared_ptr; +using namespace std; + ]],[[ +shared_ptr<string> test_ptr(new string("test string")); + ]])], + [ + ac_cv_shared_ptr_namespace="${namespace}" + ac_cv_shared_ptr_header="<${header}>" + break + ],[ + ac_cv_shared_ptr_namespace=missing + ac_cv_shared_ptr_header=missing + ]) + done + if test "$ac_cv_shared_ptr_namespace" != "missing"; then break; fi done ]) AS_IF([ test "x$ac_cv_shared_ptr_namespace" = xmissing ], @@ -60,5 +78,13 @@ shared_ptr<string> test_ptr(new string("test string")); [The namespace in which SHARED_PTR can be found]) ] ) + AS_IF([ test "x$ac_cv_shared_ptr_header" = xmissing ], + [], [ + SHARED_PTR_HEADER=${ac_cv_shared_ptr_header} + AC_DEFINE_UNQUOTED([SHARED_PTR_HEADER], + ${ac_cv_shared_ptr_header}, + [The header in which SHARED_PTR can be found]) + ] + ) AC_LANG_POP() ])