Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • D

Idiom #123 Assert condition

Verify that predicate isConsistent returns true, otherwise report assertion violation.
Explain if the assertion is executed even in production environment or not.

assert(isConsistent);

Not present in release code (except assert(0); which is special)
#include <assert.h>
assert(isConsistent());

If NDEBUG is defined, the assert macro becomes void. Therefore, such expressions must not have side effects.

New implementation...
< >
programming-idioms.org