The <cassert>
header (from the C standard <assert.h>
header) declares the assert
macro. The <cassert>
header is unique in that you
can #include
it multiple times to
obtain different effects (depending on whether the NDEBUG
macro is defined at the time of
#include
<cassert>
).
Assertions are checked at runtime. You can use templates to craft compile-time assertions. See Appendix B for information about the Boost project, which supports compile-time assertions.
Instead of assertions, consider using exceptions, which offer more flexibility and control.