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

[cleanup] Remove check and fallback code for static_assert.

Deprecate header and macro dune_static_assert.
Use static_assert instead.
parent fc625172
No related branches found
No related tags found
No related merge requests found
#
# 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>
......
......@@ -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
......
......@@ -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 {
/**
......
......@@ -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
......
......@@ -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 \
......
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
])
......@@ -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])
......
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