Skip to content
Snippets Groups Projects
Commit 5da88705 authored by Christoph Grüninger's avatar Christoph Grüninger
Browse files

[cleanup] Remove check/fallback code for variadic templates, SFINAE.

parent 876180d5
No related branches found
No related tags found
No related merge requests found
......@@ -9,8 +9,6 @@
# HAS_ATTRIBUTE_DEPRECATED True if attribute deprecated is supported
# HAS_ATTRIBUTE_DEPRECATED_MSG True if attribute deprecated("msg") is supported
# HAVE_INTEGRAL_CONSTANT True if compiler supports integral_constant
# HAVE_VARIADIC_TEMPLATES True if variadic templates are supprt
# HAVE_VARIADIC_CONSTRUCTOR_SFINAE True if variadic constructor sfinae is supported
# HAVE_RVALUE_REFERENCES True if rvalue references are supported
# HAVE_CONSTEXPR True if constexpr is supported
# HAVE_KEYWORD_FINAL True if final is supported.
......@@ -183,68 +181,6 @@ check_cxx_source_compiles("
" HAS_ATTRIBUTE_DEPRECATED_MSG
)
# variadic template support
check_cxx_source_compiles("
#include <cassert>
template<typename... T>
int addints(T... x);
int add_ints()
{
return 0;
}
template<typename T1, typename... T>
int add_ints(T1 t1, T... t)
{
return t1 + add_ints(t...);
}
int main(void)
{
assert( 5 == add_ints(9,3,-5,-2) );
return 0;
}
" HAVE_VARIADIC_TEMPLATES
)
# SFINAE on variadic template constructors within template classes
check_cxx_source_compiles("
#include <functional>
template<typename... U>
struct A
{
template<typename... T,
typename = typename std::enable_if<(sizeof...(T) < 2)>::type
>
A(T... t)
: i(1)
{}
template<typename... T,
typename = typename std::enable_if<(sizeof...(T) >= 2)>::type,
typename = void
>
A(T... t)
: i(-1)
{}
A()
: i(1)
{}
int i;
};
int main(void)
{
return (A<int>().i + A<int>(2).i + A<int>(\"foo\",3.4).i + A<int>(8,'a',A<int>()).i == 0 ? 0 : 1);
}
" HAVE_VARIADIC_CONSTRUCTOR_SFINAE
)
# rvalue references
check_cxx_source_compiles("
#include <cassert>
......
......@@ -124,12 +124,6 @@
/* end private */
/* Define to 1 if variadic templates are supported */
#cmakedefine HAVE_VARIADIC_TEMPLATES 1
/* Define to 1 if SFINAE on variadic template constructors is fully supported */
#cmakedefine HAVE_VARIADIC_CONSTRUCTOR_SFINAE 1
/* Define to 1 if rvalue references are supported */
#cmakedefine HAVE_RVALUE_REFERENCES 1
......
......@@ -277,9 +277,8 @@ namespace Dune
{
::new((void*)p)T(val);
}
#if ( HAVE_VARIADIC_TEMPLATES && HAVE_RVALUE_REFERENCES ) || DOXYGEN
#if HAVE_RVALUE_REFERENCES || DOXYGEN
//! construct an object of type T from variadic parameters
//! \note works only with newer C++ compilers
template<typename ... _Args>
void construct(pointer p, _Args&&... __args)
{
......
......@@ -82,9 +82,8 @@ namespace Dune
{
::new((void*)p)T(val);
}
#if ( HAVE_VARIADIC_TEMPLATES && HAVE_RVALUE_REFERENCES ) || DOXYGEN
#if HAVE_RVALUE_REFERENCES || DOXYGEN
//! construct an object of type T from variadic parameters
//! \note works only with newer C++ compilers
template<typename ... _Args>
void construct(pointer p, _Args&&... __args)
{
......
......@@ -1596,67 +1596,11 @@ namespace Dune {
#ifndef DOXYGEN
#if HAVE_VARIADIC_TEMPLATES
template<class... TupleArgs, class T>
struct PushBackTuple<typename Dune::tuple<TupleArgs...>, T>
{
typedef typename Dune::tuple<TupleArgs..., T> type;
};
#else
template<class T>
struct PushBackTuple< Dune::tuple<>, T>
{
typedef typename Dune::tuple<T> type;
};
template< class T1, class T>
struct PushBackTuple< Dune::tuple<T1>, T>
{
typedef typename Dune::tuple<T1, T> type;
};
template< class T1, class T2, class T>
struct PushBackTuple< Dune::tuple<T1, T2>, T>
{
typedef typename Dune::tuple<T1, T2, T> type;
};
template< class T1, class T2, class T3, class T>
struct PushBackTuple< Dune::tuple<T1, T2, T3>, T>
{
typedef typename Dune::tuple<T1, T2, T3, T> type;
};
template< class T1, class T2, class T3, class T4, class T>
struct PushBackTuple< Dune::tuple<T1, T2, T3, T4>, T>
{
typedef typename Dune::tuple<T1, T2, T3, T4, T> type;
};
template< class T1, class T2, class T3, class T4, class T5, class T>
struct PushBackTuple< Dune::tuple<T1, T2, T3, T4, T5>, T>
{
typedef typename Dune::tuple<T1, T2, T3, T4, T5, T> type;
};
template< class T1, class T2, class T3, class T4, class T5, class T6, class T>
struct PushBackTuple< Dune::tuple<T1, T2, T3, T4, T5, T6>, T>
{
typedef typename Dune::tuple<T1, T2, T3, T4, T5, T6, T> type;
};
template< class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T>
struct PushBackTuple< Dune::tuple<T1, T2, T3, T4, T5, T6, T7>, T>
{
typedef typename Dune::tuple<T1, T2, T3, T4, T5, T6, T7, T> type;
};
template< class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T>
struct PushBackTuple< Dune::tuple<T1, T2, T3, T4, T5, T6, T7, T8>, T>
{
typedef typename Dune::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T> type;
};
#endif // HAVE_VARIADIC_TEMPLATES
#endif
......@@ -1691,67 +1635,11 @@ namespace Dune {
#ifndef DOXYGEN
#if HAVE_VARIADIC_TEMPLATES
template<class... TupleArgs, class T>
struct PushFrontTuple<typename Dune::tuple<TupleArgs...>, T>
{
typedef typename Dune::tuple<T, TupleArgs...> type;
};
#else
template<class T>
struct PushFrontTuple< Dune::tuple<>, T>
{
typedef typename Dune::tuple<T> type;
};
template< class T1, class T>
struct PushFrontTuple< Dune::tuple<T1>, T>
{
typedef typename Dune::tuple<T, T1> type;
};
template< class T1, class T2, class T>
struct PushFrontTuple< Dune::tuple<T1, T2>, T>
{
typedef typename Dune::tuple<T, T1, T2> type;
};
template< class T1, class T2, class T3, class T>
struct PushFrontTuple< Dune::tuple<T1, T2, T3>, T>
{
typedef typename Dune::tuple<T, T1, T2, T3> type;
};
template< class T1, class T2, class T3, class T4, class T>
struct PushFrontTuple< Dune::tuple<T1, T2, T3, T4>, T>
{
typedef typename Dune::tuple<T, T1, T2, T3, T4> type;
};
template< class T1, class T2, class T3, class T4, class T5, class T>
struct PushFrontTuple< Dune::tuple<T1, T2, T3, T4, T5>, T>
{
typedef typename Dune::tuple<T, T1, T2, T3, T4, T5> type;
};
template< class T1, class T2, class T3, class T4, class T5, class T6, class T>
struct PushFrontTuple< Dune::tuple<T1, T2, T3, T4, T5, T6>, T>
{
typedef typename Dune::tuple<T, T1, T2, T3, T4, T5, T6> type;
};
template< class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T>
struct PushFrontTuple< Dune::tuple<T1, T2, T3, T4, T5, T6, T7>, T>
{
typedef typename Dune::tuple<T, T1, T2, T3, T4, T5, T6, T7> type;
};
template< class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T>
struct PushFrontTuple< Dune::tuple<T1, T2, T3, T4, T5, T6, T7, T8>, T>
{
typedef typename Dune::tuple<T, T1, T2, T3, T4, T5, T6, T7, T8> type;
};
#endif // HAVE_VARIADIC_TEMPLATES
#endif
......
......@@ -10,8 +10,6 @@ install(PROGRAMS
cxx0x_compiler.m4
cxx0x_rvaluereference.m4
cxx0x_nullptr.m4
cxx0x_variadic.m4
cxx0x_variadic_constructor_sfinae.m4
cxx11_constexpr.m4
cxx11_final.m4
dune.m4
......
......@@ -13,8 +13,6 @@ ALLM4S = \
cxx0x_compiler.m4 \
cxx0x_rvaluereference.m4 \
cxx0x_nullptr.m4 \
cxx0x_variadic.m4 \
cxx0x_variadic_constructor_sfinae.m4 \
cxx11_constexpr.m4 \
cxx11_final.m4 \
dune.m4 \
......
# tests for C++0x variadic template support
# the associated macro is called HAVE_VARIADIC_TEMPLATES
AC_DEFUN([VARIADIC_TEMPLATES_CHECK],[
AC_CACHE_CHECK([whether variadic templates are supported], dune_cv_variadic_templates_support, [
AC_REQUIRE([AC_PROG_CXX])
AC_REQUIRE([GXX0X])
AC_LANG_PUSH([C++])
AC_RUN_IFELSE([
AC_LANG_PROGRAM([#include<cassert>
template<typename... T>
int addints(T... x);
int add_ints()
{
return 0;
}
template<typename T1, typename... T>
int add_ints(T1 t1, T... t)
{
return t1 + add_ints(t...);
}],
[
assert( 5 == add_ints(9,3,-5,-2) );
return 0;
])],
dune_cv_variadic_templates_support=yes,
dune_cv_variadic_templates_support=no)
AC_LANG_POP
])
if test "x$dune_cv_variadic_templates_support" = xyes; then
AC_DEFINE(HAVE_VARIADIC_TEMPLATES, 1, [Define to 1 if variadic templates are supported])
fi
])
# tests whether the compiler supports SFINAE on variadic template constructors
# within template classes. GCC 4.3 fails this test.
# the associated macro is called HAVE_VARIADIC_CONSTRUCTOR_SFINAE
AC_DEFUN([VARIADIC_CONSTRUCTOR_SFINAE_CHECK],[
AC_CACHE_CHECK([whether SFINAE on variadic template constructors is fully supported],
dune_cv_variadic_constructor_sfinae_support, [
AC_REQUIRE([AC_PROG_CXX])
AC_REQUIRE([GXX0X])
AC_LANG_PUSH([C++])
AC_RUN_IFELSE([
AC_LANG_PROGRAM([
#include <functional>
template<typename... U>
struct A
{
template<typename... T,
typename = typename std::enable_if<(sizeof...(T) < 2)>::type
>
A(T... t)
: i(1)
{}
template<typename... T,
typename = typename std::enable_if<(sizeof...(T) >= 2)>::type,
typename = void
>
A(T... t)
: i(-1)
{}
A()
: i(1)
{}
int i;
};],
[
return (A<int>().i + A<int>(2).i + A<int>("foo",3.4).i + A<int>(8,'a',A<int>()).i == 0 ? 0 : 1);
])],
dune_cv_variadic_constructor_sfinae_support=yes,
dune_cv_variadic_constructor_sfinae_support=no)
AC_LANG_POP
])
AS_IF([test "x$dune_cv_variadic_constructor_sfinae_support" = xyes],[
AC_DEFINE(HAVE_VARIADIC_CONSTRUCTOR_SFINAE, 1, [Define to 1 if SFINAE on variadic template constructors is fully supported])
])
])
......@@ -20,7 +20,6 @@ AC_DEFUN([DUNE_COMMON_CHECKS],
AC_REQUIRE([DUNE_CHECK_COMPILER])
AC_REQUIRE([GXX0X])
AC_REQUIRE([NULLPTR_CHECK])
AC_REQUIRE([VARIADIC_TEMPLATES_CHECK])
AC_REQUIRE([RVALUE_REFERENCES_CHECK])
AC_REQUIRE([CXX11_CONSTEXPR_CHECK])
AC_REQUIRE([DUNE_BOOST_BASE])
......
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