]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Assert: guard new release variant with DEAL_II_HAVE_CXX20
authorMatthias Maier <tamiko@43-1.org>
Wed, 14 Aug 2024 16:56:47 +0000 (11:56 -0500)
committerMatthias Maier <tamiko@43-1.org>
Wed, 14 Aug 2024 16:56:47 +0000 (11:56 -0500)
include/deal.II/base/exceptions.h

index 9c3f6b051548df61b1e38b3affc638639b8a75d9..95d755470a18a3ebbbf2751941c718bf96e923a0 100644 (file)
@@ -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<decltype(cond)>::type \
-          *dealii_assert_variable_a = nullptr;               \
-        typename std::remove_reference<decltype(exc)>::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<decltype(cond)>::type \
+            *dealii_assert_variable_a = nullptr;               \
+          typename std::remove_reference<decltype(exc)>::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*/
 
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.