Suggestion for extra jassert() functionality

This can be simplified to:

if (prerequisite && !expression) jassertfalse;

Or:

jassert(!prerequisite || expression);
jassert(!if_this_is_true || test_this_and_that);

The !prerequisite || expression means: “If prerequisite is false, pass without checking expression. If prerequisite is true, check expression”.

Note that this is different from the suggestion so far:

jassert(if_this_is_true && test_this_and_that);

This one would fail the assertion if if_this_is_true is false. But you want to skip the entire jassert check in that case.
It would also skip (pass) the check if if_this_is_true is true. Which is the opposite from what you asked.

2 Likes