Assertion with an optional message
Opened this issue · 0 comments
Feature request
Is your feature request related to a problem? Please describe.
I would like to test for preconditions and postconditions, but only when compiled in debug mode. Printing a message why something fails is useful. On the other hand, T8_ASSERT
, similarly to the built-in assert
, only accepts an expression, no optional message.
Describe the solution or feature you'd like
A convenience macro, e.g. T8_ASSERTF
would be nice.
Describe alternatives you've considered
To achieve the same effect, we now need to use the more verbose
#if T8_ENABLE_DEBUG
if (!condition)
SC_ABORTF("Error message");
#endif
Alternatively, Boost has BOOST_ASSERT_MSG
. There are other tricks, such as
assert(("Error message", condition));
See StackOverflow for more details.
Estimated priority
"Priority: low" Should be solved eventually
Additional context
This feature request concerns assertions, not logging. For that, functions such as t8_global_productionf
already exist.