#
# DEAL_II_HAVE_ATTRIBUTE_FALLTHROUGH
# DEAL_II_HAVE_CXX11_IS_TRIVIALLY_COPYABLE
+# DEAL_II_HAVE_CXX14_CONSTEXPR_CAN_CALL_NONCONSTEXPR
# DEAL_II_HAVE_CXX17_SPECIAL_MATH_FUNCTIONS
# DEAL_II_HAVE_FP_EXCEPTIONS
# DEAL_II_HAVE_COMPLEX_OPERATOR_OVERLOADS
"${CMAKE_REQUIRED_FLAGS}${DEAL_II_CXX_VERSION_FLAG}${DEAL_II_WITH_CXX14}${DEAL_II_WITH_CXX17}"
DEAL_II_HAVE_ATTRIBUTE_FALLTHROUGH
DEAL_II_HAVE_CXX11_IS_TRIVIALLY_COPYABLE
+ DEAL_II_HAVE_CXX14_CONSTEXPR_CAN_CALL_NONCONSTEXPR
DEAL_II_HAVE_CXX17_SPECIAL_MATH_FUNCTIONS
DEAL_II_HAVE_FP_EXCEPTIONS
DEAL_II_HAVE_COMPLEX_OPERATOR_OVERLOADS
"
DEAL_II_HAVE_COMPLEX_OPERATOR_OVERLOADS)
+#
+# As long as there exists an argument value such that an invocation of the
+# function or constructor could be an evaluated subexpression of a core constant
+# expression, C++14 allows to call non-constexpr functions from constexpr
+# functions. Unfortunately, not all compilers obey the standard in this regard.
+#
+CHECK_CXX_SOURCE_COMPILES(
+ "
+ void bar()
+ {}
+
+ constexpr int
+ foo(const int n)
+ {
+ if(!(n >= 0))
+ bar();
+ return n;
+ }
+
+ int main()
+ {
+ constexpr unsigned int n=foo(1);
+ return n;
+ }
+ "
+ DEAL_II_HAVE_CXX14_CONSTEXPR_CAN_CALL_NONCONSTEXPR)
+
#
# Not all compilers with C++17 support include the new special math
# functions. Check this separately so that we can use C++17 compilers that don't
*/
#cmakedefine DEAL_II_HAVE_CXX11_IS_TRIVIALLY_COPYABLE
+#cmakedefine DEAL_II_HAVE_CXX14_CONSTEXPR_CAN_CALL_NONCONSTEXPR
#cmakedefine DEAL_II_HAVE_CXX17_SPECIAL_MATH_FUNCTIONS
#cmakedefine DEAL_II_HAVE_FP_EXCEPTIONS
#cmakedefine DEAL_II_HAVE_COMPLEX_OPERATOR_OVERLOADS
pow(const unsigned int base, const int iexp)
{
#ifdef DEAL_II_WITH_CXX14
-# if defined(DEAL_II_HAVE_BUILTIN_EXPECT) && defined(__INTEL_COMPILER)
+# ifdef DEAL_II_HAVE_CXX14_CONSTEXPR_CAN_CALL_NONCONSTEXPR
+# if defined(DEAL_II_HAVE_BUILTIN_EXPECT) && defined(__INTEL_COMPILER)
if (!(iexp >= 0))
::dealii::deal_II_exceptions::internals::issue_error_noreturn(
::dealii::deal_II_exceptions::internals::abort_or_throw_on_exception,
"iexp>=0",
"ExcMessage(\"The exponent must not be negative!\")",
ExcMessage("The exponent must not be negative!"));
-# else
+# else
Assert(iexp >= 0, ExcMessage("The exponent must not be negative!"));
+# endif
# endif
#endif
// The "exponentiation by squaring" algorithm used below has to be