© Peter Van Weert and Marc Gregoire 2019
Peter Van Weert and Marc GregoireC++17 Standard Library Quick Referencehttps://doi.org/10.1007/978-1-4842-4923-9_8

8. Diagnostics

Peter Van Weert1  and Marc Gregoire2
(1)
Kessel-Lo, Belgium
(2)
Meldert, Belgium
 

Assertions <cassert>

Assertions are Boolean expressions that are expected to be true at a given point in the code. The assert macro of <cassert> is defined similar to
#ifdef NDEBUG
 #define assert(_)
#else
 #define assert(CONDITION) \
   if (!(CONDITION)) { print_msg(__FILE__, __LINE__, ...); std::abort(); }
#endif

If an assertion fails, a diagnostic message is written to the standard error output, and std::abort() is called which terminates the application without performing any cleanup. The diagnostic message ...

Get C++17 Standard Library Quick Reference: A Pocket Guide to Data Structures, Algorithms, and Functions 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.