From 5da88705e93ea4173c2a388c92b41ad4f5c37be8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Gr=C3=BCninger?= <gruenich@dune-project.org> Date: Sat, 22 Mar 2014 15:20:09 +0100 Subject: [PATCH] [cleanup] Remove check/fallback code for variadic templates, SFINAE. --- cmake/modules/CheckCXX11Features.cmake | 64 -------------- config.h.cmake | 6 -- dune/common/debugallocator.hh | 3 +- dune/common/mallocallocator.hh | 3 +- dune/common/tupleutility.hh | 112 ------------------------ m4/CMakeLists.txt | 2 - m4/Makefile.am | 2 - m4/cxx0x_variadic.m4 | 36 -------- m4/cxx0x_variadic_constructor_sfinae.m4 | 50 ----------- m4/dune_common.m4 | 1 - 10 files changed, 2 insertions(+), 277 deletions(-) delete mode 100644 m4/cxx0x_variadic.m4 delete mode 100644 m4/cxx0x_variadic_constructor_sfinae.m4 diff --git a/cmake/modules/CheckCXX11Features.cmake b/cmake/modules/CheckCXX11Features.cmake index c44feeeb3..9f3cd9ecb 100644 --- a/cmake/modules/CheckCXX11Features.cmake +++ b/cmake/modules/CheckCXX11Features.cmake @@ -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> diff --git a/config.h.cmake b/config.h.cmake index e50712c5e..4b508260a 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -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 diff --git a/dune/common/debugallocator.hh b/dune/common/debugallocator.hh index fd50ab044..1327a2996 100644 --- a/dune/common/debugallocator.hh +++ b/dune/common/debugallocator.hh @@ -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) { diff --git a/dune/common/mallocallocator.hh b/dune/common/mallocallocator.hh index 8b27c0737..4892e947f 100644 --- a/dune/common/mallocallocator.hh +++ b/dune/common/mallocallocator.hh @@ -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) { diff --git a/dune/common/tupleutility.hh b/dune/common/tupleutility.hh index cf0abf819..41ca3170a 100644 --- a/dune/common/tupleutility.hh +++ b/dune/common/tupleutility.hh @@ -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 diff --git a/m4/CMakeLists.txt b/m4/CMakeLists.txt index ad4a1af46..e089cce1b 100644 --- a/m4/CMakeLists.txt +++ b/m4/CMakeLists.txt @@ -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 diff --git a/m4/Makefile.am b/m4/Makefile.am index e297c5179..f1672927f 100644 --- a/m4/Makefile.am +++ b/m4/Makefile.am @@ -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 \ diff --git a/m4/cxx0x_variadic.m4 b/m4/cxx0x_variadic.m4 deleted file mode 100644 index fadecf0f2..000000000 --- a/m4/cxx0x_variadic.m4 +++ /dev/null @@ -1,36 +0,0 @@ -# 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 -]) diff --git a/m4/cxx0x_variadic_constructor_sfinae.m4 b/m4/cxx0x_variadic_constructor_sfinae.m4 deleted file mode 100644 index f8adc4fe8..000000000 --- a/m4/cxx0x_variadic_constructor_sfinae.m4 +++ /dev/null @@ -1,50 +0,0 @@ -# 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]) - ]) -]) diff --git a/m4/dune_common.m4 b/m4/dune_common.m4 index e6e1b5332..ddf634cda 100644 --- a/m4/dune_common.m4 +++ b/m4/dune_common.m4 @@ -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]) -- GitLab