assert
From cppreference.com
Defined in header <cassert>
|
||
Disabled assertion |
||
(1) | ||
#define assert(condition) ((void)0) |
(until C++26) | |
#define assert(...) ((void)0) |
(since C++26) | |
Enabled assertion |
||
(2) | ||
#define assert(condition) /* unspecified */ |
(until C++26) | |
#define assert(...) /* unspecified */ |
(since C++26) | |
The definition of the macro assert
depends on another macro, NDEBUG, which is not defined by the standard library.
1) If NDEBUG is defined as a macro name at the point in the source code where <cassert> or <assert.h> is included, the assertion is disabled:
assert
does nothing.2) Otherwise, the assertion is enabled:
|
(until C++26) |
|
(since C++26) |
The diagnostic information has an implementation-defined format, but it always includes the following information:
|
(until C++26) |
|
(since C++26) |
- the source file name (i.e., __FILE__)
- the source line number (i.e., __LINE__)
- the name of the enclosing function (i.e., __func__)
The expression assert(E) is guaranteed to be a constant subexpression, if either
|
(since C++11) |
Contents |
[edit] Parameters
condition | - | expression of scalar type |