Skip to content
Snippets Groups Projects
Commit a35de714 authored by Martin Nolte's avatar Martin Nolte
Browse files

only use std::integral_constant, if it conforms to the C++11 standard

C++11 requires a cast operator from integral_constant< T, v > to T. As far as I
could make out, no gcc version provides this cast in <tr1/type_traits> and only
gcc >= 4.6 provides it in <type_traits>. Therefore, the configure check now tests
for the cast operator only in <type_traits>.

Note: Our drop-in replacement conforms to the standard in the above-mentioned
sense.

[[Imported from SVN: r6992]]
parent 54e77c9f
No related branches found
No related tags found
No related merge requests found
......@@ -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
/** @} */
}
......
......@@ -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++])
])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment