From eaccce7e8bfbbae67464aed38284eacefb8cd137 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Gr=C3=BCninger?= <gruenich@dune-project.org> Date: Sat, 22 Mar 2014 09:41:01 +0100 Subject: [PATCH] [cleanup] Remove check and fallback code for static_assert. Deprecate header and macro dune_static_assert. Use static_assert instead. --- cmake/modules/CheckCXX11Features.cmake | 15 +++---------- config.h.cmake | 3 --- dune/common/static_assert.hh | 31 +++----------------------- m4/CMakeLists.txt | 1 - m4/Makefile.am | 1 - m4/cxx0x_static_assert.m4 | 15 ------------- m4/dune_common.m4 | 1 - 7 files changed, 6 insertions(+), 61 deletions(-) delete mode 100644 m4/cxx0x_static_assert.m4 diff --git a/cmake/modules/CheckCXX11Features.cmake b/cmake/modules/CheckCXX11Features.cmake index 78d048d2c..35dbf6b5d 100644 --- a/cmake/modules/CheckCXX11Features.cmake +++ b/cmake/modules/CheckCXX11Features.cmake @@ -1,7 +1,7 @@ # # Module that checks for supported C++11 (former C++0x) features. # -# Sets the follwing variable: +# Sets the follwing variables: # # HAVE_NULLPTR True if nullptr is available # HAVE_ARRAY True if header <array> and fill() are available @@ -10,12 +10,13 @@ # 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_STATIC_ASSERT True if static_assert is available # 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_STD_CONDITIONAL True if std::conditional is supported # HAVE_INITIALIZER_LIST True if initializer list is supported +# HAVE_CONSTEXPR True if constexpr is supported +# HAVE_KEYWORD_FINAL True if final is supported. include(CMakePushCheckState) cmake_push_check_state() @@ -198,16 +199,6 @@ check_cxx_source_compiles(" " HAS_ATTRIBUTE_DEPRECATED_MSG ) -# static assert -check_cxx_source_compiles(" - int main(void) - { - static_assert(true,\"MSG\"); - return 0; - } -" HAVE_STATIC_ASSERT -) - # variadic template support check_cxx_source_compiles(" #include <cassert> diff --git a/config.h.cmake b/config.h.cmake index 9c0b16918..3b21e5e41 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -76,9 +76,6 @@ /* Define to 1 if nullptr is supported */ #cmakedefine HAVE_NULLPTR 1 -/* Define to 1 if static_assert is supported */ -#cmakedefine HAVE_STATIC_ASSERT 1 - /* Define to 1 if you have the <stdint.h> header file. */ #cmakedefine HAVE_STDINT_H 1 diff --git a/dune/common/static_assert.hh b/dune/common/static_assert.hh index 510cf8c79..f91982bf4 100644 --- a/dune/common/static_assert.hh +++ b/dune/common/static_assert.hh @@ -3,6 +3,8 @@ #ifndef DUNE_STATIC_ASSERT_HH #define DUNE_STATIC_ASSERT_HH +#warning This header and the macro dune_static_assert are deprecated, use static_assert instead. + /** \file * \brief Fallback implementation of the C++0x static_assert feature */ @@ -13,27 +15,6 @@ * @{ */ -#if not HAVE_STATIC_ASSERT -// Taken from BOOST -// -// Helper macro CPPMAGIC_JOIN: -// The following piece of macro magic joins the two -// arguments together, even when one of the arguments is -// itself a macro (see 16.3.1 in C++ standard). The key -// is that macro expansion of macro arguments does not -// occur in CPPMAGIC_DO_JOIN2 but does in CPPMAGIC_DO_JOIN. -// -#define CPPMAGIC_JOIN( X, Y ) CPPMAGIC_DO_JOIN( X, Y ) -#define CPPMAGIC_DO_JOIN( X, Y ) CPPMAGIC_DO_JOIN2(X,Y) -#define CPPMAGIC_DO_JOIN2( X, Y ) X ## Y - -template <bool x> struct static_assert_failure; - -template <> struct static_assert_failure<true> { }; - -template<int x> struct static_assert_test {}; -#endif - /** \brief Helper template so that compilation fails if condition is not true. @@ -70,17 +51,11 @@ template<int x> struct static_assert_test {}; This is because dune_static_assert is a preprocessor macro</li> </ol> + \deprecated Use static_assert from C++11 instead. */ -#if HAVE_STATIC_ASSERT #define dune_static_assert(COND,MSG) \ static_assert(COND,MSG) -#else -#define dune_static_assert(COND,MSG) \ - typedef static_assert_test< \ - sizeof(static_assert_failure< (bool)( COND )>)\ - > CPPMAGIC_JOIN (dune_static_assert_typedef_, __LINE__) -#endif namespace Dune { /** diff --git a/m4/CMakeLists.txt b/m4/CMakeLists.txt index c60a1a2ba..20f293591 100644 --- a/m4/CMakeLists.txt +++ b/m4/CMakeLists.txt @@ -10,7 +10,6 @@ install(PROGRAMS cxx0x_compiler.m4 cxx0x_rvaluereference.m4 cxx0x_nullptr.m4 - cxx0x_static_assert.m4 cxx0x_variadic.m4 cxx0x_variadic_constructor_sfinae.m4 cxx11_constexpr.m4 diff --git a/m4/Makefile.am b/m4/Makefile.am index 40ad9775d..ce7f3c9b5 100644 --- a/m4/Makefile.am +++ b/m4/Makefile.am @@ -13,7 +13,6 @@ ALLM4S = \ cxx0x_compiler.m4 \ cxx0x_rvaluereference.m4 \ cxx0x_nullptr.m4 \ - cxx0x_static_assert.m4 \ cxx0x_variadic.m4 \ cxx0x_variadic_constructor_sfinae.m4 \ cxx11_initializer_list.m4 \ diff --git a/m4/cxx0x_static_assert.m4 b/m4/cxx0x_static_assert.m4 deleted file mode 100644 index 3cead1a7d..000000000 --- a/m4/cxx0x_static_assert.m4 +++ /dev/null @@ -1,15 +0,0 @@ -AC_DEFUN([STATIC_ASSERT_CHECK],[ - AC_CACHE_CHECK([whether static_assert is supported], dune_cv_static_assert_support, [ - AC_REQUIRE([AC_PROG_CXX]) - AC_REQUIRE([GXX0X]) - AC_LANG_PUSH([C++]) - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([], [[static_assert(true,"MSG")]])], - dune_cv_static_assert_support=yes, - dune_cv_static_assert_support=no) - AC_LANG_POP - ]) - if test "x$dune_cv_static_assert_support" = xyes; then - AC_DEFINE(HAVE_STATIC_ASSERT, 1, [Define to 1 if static_assert is supported]) - fi -]) diff --git a/m4/dune_common.m4 b/m4/dune_common.m4 index b2b68ceb7..792d4fea4 100644 --- a/m4/dune_common.m4 +++ b/m4/dune_common.m4 @@ -19,7 +19,6 @@ AC_DEFUN([DUNE_COMMON_CHECKS], AC_REQUIRE([DUNE_CHECK_COMPILER]) AC_REQUIRE([GXX0X]) - AC_REQUIRE([STATIC_ASSERT_CHECK]) AC_REQUIRE([NULLPTR_CHECK]) AC_REQUIRE([SHARED_PTR]) AC_REQUIRE([VARIADIC_TEMPLATES_CHECK]) -- GitLab