diff --git a/dune/common/typetraits.hh b/dune/common/typetraits.hh index 40c1f67f2129ac89ab6b85c41ccf4aae4f130014..561086be632e88eb429b28b1cf6b5a4bb32deb35 100644 --- a/dune/common/typetraits.hh +++ b/dune/common/typetraits.hh @@ -395,15 +395,11 @@ namespace Dune // // integral_constant (C++0x 20.7.3 "Helper classes") // -#if defined HAVE_TYPE_TRAITS +#if HAVE_INTEGRAL_CONSTANT using std::integral_constant; using std::true_type; using std::false_type; -#elif defined HAVE_TR1_TYPE_TRAITS - using std::tr1::integral_constant; - using std::tr1::true_type; - using std::tr1::false_type; -#else +#else // #if HAVE_INTEGRAL_CONSTANT //! Generate a type for a given integral constant /** * \tparam T Type of the constant. @@ -425,7 +421,7 @@ namespace Dune typedef integral_constant<bool, true> true_type; //! type for false typedef integral_constant<bool, false> false_type; -#endif +#endif // #else // #if HAVE_INTEGRAL_CONSTANT /** @} */ } diff --git a/m4/dune_tr1_headers.m4 b/m4/dune_tr1_headers.m4 index ec04516ce9f9236d41a40b359626119172417dfa..d9a0807aacb5fd6a0cf1b989d7dd438684f55274 100644 --- a/m4/dune_tr1_headers.m4 +++ b/m4/dune_tr1_headers.m4 @@ -20,6 +20,23 @@ AC_DEFUN([DUNE_TR1_HEADERS], [ AS_IF([test "x$dune_cv_array_cplusplus0x" != "xno"], [AC_DEFINE([HAVE_ARRAY], 1, [Define to 1 if the <array> C++0x is available and support array::fill]) ]) + AC_CACHE_CHECK([whether integral_constant conforming to C++11 is supported], dune_cv_integral_constant_cplusplus11, [ + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([ + #include <type_traits> + void f( int ); + ],[ + f( std::integral_constant< int, 42 >() ); + ]) + ],[ + dune_cv_integral_constant_cplusplus11=yes + ],[ + dune_cv_integral_constant_cplusplus11=no + ]) + ]) + AS_IF([test "x$dune_cv_integral_constant_cplusplus11" != "xno"],[ + AC_DEFINE([HAVE_INTEGRAL_CONSTANT], 1, [Define to 1 if std::integral_constant< T, v > is supported and casts into T]) + ]) ]) AC_LANG_POP([C++]) ])