<cassert>
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.
Get C++ In a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.