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

Merge branch 'feature/noexcept'

Conflicts:
	cmake/modules/CheckCXX11Features.cmake
	dune/common/std/CMakeLists.txt
	dune/common/std/Makefile.am
	m4/Makefile.am
	m4/dune_common.m4
parents 10ece11c 6db0ffcd
No related branches found
No related tags found
No related merge requests found
......@@ -10,6 +10,7 @@
# HAVE_CONSTEXPR True if constexpr is supported
# HAVE_KEYWORD_FINAL True if final is supported.
# HAVE_RANGE_BASED_FOR True if range-based for is supported and working.
# HAVE_NOEXCEPT_SPECIFIER True if nonexcept specifier is supported.
include(CMakePushCheckState)
cmake_push_check_state()
......@@ -178,4 +179,22 @@ check_cxx_source_compiles("
" HAVE_RANGE_BASED_FOR
)
# nonexcept specifier
check_cxx_source_compiles("
void func1() noexcept {}
void func2() noexcept(true) {}
template <class T>
void func3() noexcept(noexcept(T())) {}
int main(void)
{
func1();
func2();
func3<int>();
}
" HAVE_NOEXCEPT_SPECIFIER
)
cmake_pop_check_state()
......@@ -107,6 +107,9 @@
/* Define to 1 if C++11 constexpr is supported */
#cmakedefine HAVE_CONSTEXPR 1
/* Define to 1 if C++11 nonexcept specifier is supported */
#cmakedefine HAVE_NOEXCEPT_SPECIFIER 1
/* does the compiler support the keyword 'final'? */
#cmakedefine HAVE_KEYWORD_FINAL 1
......
install(FILES
constexpr.hh
final.hh
type_traits.hh
utility.hh
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dune/common/std)
install(
FILES
constexpr.hh
final.hh
noexcept.hh
type_traits.hh
utility.hh
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dune/common/std)
......@@ -2,6 +2,7 @@ stdincludedir = $(includedir)/dune/common/std
stdinclude_HEADERS = \
constexpr.hh \
final.hh \
noexcept.hh \
type_traits.hh \
utility.hh
......
#ifndef DUNE_COMMON_STD_NOEXCEPT_HH
#define DUNE_COMMON_STD_NOEXCEPT_HH
/**
* \file
* \brief Definition of the DUNE_NOEXCEPT macro
*/
#if HAVE_NOEXCEPT_SPECIFIER || defined(DOXYGEN)
/**
* \brief Set method to noexcept if supported by the compiler.
* \code
#include <dune/common/std/noexcept.hh>
* \endcode
*
* This is a preprocessor define which can be used to mark methods as
* noexcept.
*
* \note This does not support the noexcept operator.
*/
#define DUNE_NOEXCEPT noexcept
#else
#define DUNE_NOEXCEPT
#endif // HAVE_NOEXCEPT_SPECIFIER || defined(DOXYGEN)
#endif // DUNE_COMMON_STD_NOEXCEPT_HH
......@@ -14,6 +14,7 @@ ALLM4S = \
cxx0x_nullptr.m4 \
cxx11_constexpr.m4 \
cxx11_final.m4 \
cxx11_noexcept.m4 \
cxx11_range_based_for.m4 \
dune.m4 \
dune_all.m4 \
......
# tests for C++11 noexcept specifier support
# this test does not test the noexcept operator
# the associated macro is called HAVE_NOEXCEPT_SPECIFIER
AC_DEFUN([DUNE_CXX11_NOEXCEPT_SPECIFIER_CHECK],[
AC_CACHE_CHECK([for C++11 noexcept specifier],
dune_cv_cxx11_noexcept_specifier_support,
[
AC_REQUIRE([AC_PROG_CXX])
AC_REQUIRE([CXX11])
AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM(
[
void func1() noexcept {}
void func2() noexcept(true) {}
template <class T>
void func3() noexcept(noexcept(T())) {}
],[
func1();
func2();
func3<int>();
])],
dune_cv_cxx11_noexcept_specifier_support=yes,
dune_cv_cxx11_noexcept_specifier_support=no)
AC_LANG_POP
])
if test "$dune_cv_cxx11_noexcept_specifier_support" = yes; then
AC_DEFINE(HAVE_NOEXCEPT_SPECIFIER, 1,
[Define to 1 if C++11 nonexcept specifier is supported])
fi
])
......@@ -21,6 +21,7 @@ AC_DEFUN([DUNE_COMMON_CHECKS],
AC_REQUIRE([CXX11])
AC_REQUIRE([NULLPTR_CHECK])
AC_REQUIRE([CXX11_CONSTEXPR_CHECK])
AC_REQUIRE([DUNE_CXX11_NOEXCEPT_SPECIFIER_CHECK])
AC_REQUIRE([DUNE_CXX11_RANGE_BASED_FOR])
AC_REQUIRE([DUNE_BOOST_BASE])
AC_REQUIRE([DUNE_LINKCXX])
......
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