#
# DEAL_II_HAVE_CXX14
# DEAL_II_HAVE_CXX17
+# DEAL_II_HAVE_CXX20
#
# DEAL_II_HAVE_FP_EXCEPTIONS
# DEAL_II_HAVE_COMPLEX_OPERATOR_OVERLOADS
ENDMACRO()
+#
+# Wrap the following checks into a macro to make it easier to rerun them.
+#
+MACRO(_test_cxx20_support)
+
+ UNSET_IF_CHANGED(CHECK_CXX20_FEATURES_FLAGS_SAVED
+ "${CMAKE_REQUIRED_FLAGS}"
+ DEAL_II_HAVE_CXX20_FEATURES
+ )
+
+ # Strictly speaking "201709L" indicates support for a preliminary version
+ # of C++20 standard (which will have "202002L" when finalized). gcc-10
+ # exports this version number when configured with C++20 support.
+ # clang-10 exports the final "202002L" version instead.
+ CHECK_CXX_SOURCE_COMPILES(
+ "
+ #include <cmath>
+ #include <ranges>
+
+ #if __cplusplus < 201709L && !defined(_MSC_VER) && !defined(__INTEL_COMPILER)
+ # error \"insufficient support for C++20\"
+ #endif
+
+ #if !(defined __cpp_lib_ranges) || (__cpp_lib_ranges < 201911)
+ # error \"insufficient support for C++20\"
+ #endif
+
+ int main()
+ {
+ }
+ "
+ DEAL_II_HAVE_CXX20_FEATURES)
+
+ IF(DEAL_II_HAVE_CXX20_FEATURES)
+ MESSAGE(STATUS "C++20 support is enabled.")
+ SET(DEAL_II_HAVE_CXX20 TRUE)
+ ELSE()
+ MESSAGE(STATUS "C++20 support is disabled.")
+ SET(DEAL_II_HAVE_CXX20 FALSE)
+ ENDIF()
+ENDMACRO()
+
+
#
# Wrap the following checks into a macro to make it easier to rerun them.
#
ENDIF()
ENDMACRO()
+
#
# Try to find out what we support:
#
ENDIF()
_test_cxx17_support()
+_test_cxx20_support()
########################################################################
#cmakedefine DEAL_II_HAVE_CXX14
#cmakedefine DEAL_II_HAVE_CXX17
+#cmakedefine DEAL_II_HAVE_CXX20
#cmakedefine DEAL_II_HAVE_FP_EXCEPTIONS
#cmakedefine DEAL_II_HAVE_COMPLEX_OPERATOR_OVERLOADS
#include <deal.II/base/config.h>
-#if defined __cpp_lib_ranges && __cpp_lib_ranges >= 201911
+#ifdef DEAL_II_HAVE_CXX20
# include <ranges>
#else
# include <boost/range/irange.hpp>
{
namespace ranges
{
-#if defined __cpp_lib_ranges && __cpp_lib_ranges >= 201911
- using std::ranges::iota_view;
-#else
+#ifndef DEAL_II_HAVE_CXX20
/**
* A poor-man's implementation of std::ranges::iota_view using
* boost's integer_range class. The two classes are not completely
*/
template <typename IncrementableType, typename /*BoundType*/>
using iota_view = boost::integer_range<IncrementableType>;
+#else
+ using std::ranges::iota_view;
#endif
} // namespace ranges
} // namespace std_cxx20