Skip to content

Commit

Permalink
Assert: guard new release variant with DEAL_II_HAVE_CXX20
Browse files Browse the repository at this point in the history
  • Loading branch information
tamiko committed Aug 14, 2024
1 parent 18cc381 commit 6b6e424
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions include/deal.II/base/exceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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*/


Expand Down

0 comments on commit 6b6e424

Please sign in to comment.