Bond 0.9
C++ Bond Runtime Library API Documentation
Loading...
Searching...
No Matches
assert.h File Reference

Debugging asserts for catching logic errors during development. More...

#include "bond/conf.h"
#include "bond/private/assert.h"

Detailed Description

Debugging asserts for catching logic errors during development.

  • BOND_ASSERT(condition), BOND_ASSERT_MESSAGE(condition, message) and BOND_ASSERT_FORMAT(condition, format, ...) report the failure to stderr and abort the program when the condition is false.
  • BOND_ASSERT_FAIL() unconditionally reports a failure and aborts, e.g. for unreachable code.

These macros are only enabled when BOND_ASSERTS_ENABLED is non-zero (the default). Otherwise, their conditions are still type checked but are not evaluated, and they have no effect. They do not throw, so they are safe to use in destructors and noexcept functions. Conditions that depend on program input must instead be validated with the always enabled macros in bond/systems/error.h.

The default implementation can be replaced by defining USER_BOND_ASSERT_HEADER. A replacement must define all four macros.