From 6b6e4243e0f01f240f5bd6d075d93522951ceb17 Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Wed, 14 Aug 2024 11:56:47 -0500 Subject: [PATCH] Assert: guard new release variant with DEAL_II_HAVE_CXX20 --- include/deal.II/base/exceptions.h | 33 +++++++++++++++++++------------ 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/include/deal.II/base/exceptions.h b/include/deal.II/base/exceptions.h index 9c3f6b0515..95d755470a 100644 --- a/include/deal.II/base/exceptions.h +++ b/include/deal.II/base/exceptions.h @@ -1659,24 +1659,31 @@ namespace deal_II_exceptions # endif /*ifdef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST*/ # endif /*KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST*/ #else /*ifdef DEBUG*/ +# ifdef DEAL_II_HAVE_CXX20 /* * In order to avoid unused parameters (etc.) warnings we need to use cond * and exc without actually evaluating the expression and generating code. * We accomplish this by using decltype(...) and create a dummy pointer - * with these signatures. + * with these signatures. Notably, this approach works with C++20 onwards. */ -# define Assert(cond, exc) \ - do \ - { \ - typename std::remove_reference::type \ - *dealii_assert_variable_a = nullptr; \ - typename std::remove_reference::type \ - *dealii_assert_variable_b = nullptr; \ - (void)dealii_assert_variable_a; \ - (void)dealii_assert_variable_b; \ - } \ - while (false) - +# define Assert(cond, exc) \ + do \ + { \ + typename std::remove_reference::type \ + *dealii_assert_variable_a = nullptr; \ + typename std::remove_reference::type \ + *dealii_assert_variable_b = nullptr; \ + (void)dealii_assert_variable_a; \ + (void)dealii_assert_variable_b; \ + } \ + while (false) +# else +# define Assert(cond, exc) \ + do \ + { \ + } \ + while (false) +# endif #endif /*ifdef DEBUG*/ -- 2.39.5