© 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
Kessel-Lo, Belgium
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(_)
 #define assert(CONDITION) \
   if (!(CONDITION)) { print_msg(__FILE__, __LINE__, ...); std::abort(); }

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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.