tmp/tmpdoqfykz_/{from.md → to.md}
RENAMED
|
@@ -1,25 +1,46 @@
|
|
| 1 |
## Assertions <a id="assertions">[[assertions]]</a>
|
| 2 |
|
| 3 |
### General <a id="assertions.general">[[assertions.general]]</a>
|
| 4 |
|
| 5 |
The header `<cassert>` provides a macro for documenting C++ program
|
| 6 |
-
assertions and a mechanism for disabling the assertion checks
|
|
|
|
| 7 |
|
| 8 |
### Header `<cassert>` synopsis <a id="cassert.syn">[[cassert.syn]]</a>
|
| 9 |
|
| 10 |
``` cpp
|
| 11 |
-
#define assert(
|
| 12 |
```
|
| 13 |
|
| 14 |
-
The contents are the same as the C standard library header `<assert.h>`,
|
| 15 |
-
except that a macro named `static_assert` is not defined.
|
| 16 |
-
|
| 17 |
-
See also: ISO C 7.2
|
| 18 |
-
|
| 19 |
### The `assert` macro <a id="assertions.assert">[[assertions.assert]]</a>
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
An expression `assert(E)` is a constant subexpression
|
| 22 |
[[defns.const.subexpr]], if
|
| 23 |
|
| 24 |
- `NDEBUG` is defined at the point where `assert` is last defined or
|
| 25 |
redefined, or
|
|
|
|
| 1 |
## Assertions <a id="assertions">[[assertions]]</a>
|
| 2 |
|
| 3 |
### General <a id="assertions.general">[[assertions.general]]</a>
|
| 4 |
|
| 5 |
The header `<cassert>` provides a macro for documenting C++ program
|
| 6 |
+
assertions and a mechanism for disabling the assertion checks through
|
| 7 |
+
defining the macro `NDEBUG`.
|
| 8 |
|
| 9 |
### Header `<cassert>` synopsis <a id="cassert.syn">[[cassert.syn]]</a>
|
| 10 |
|
| 11 |
``` cpp
|
| 12 |
+
#define assert(...) see below
|
| 13 |
```
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
### The `assert` macro <a id="assertions.assert">[[assertions.assert]]</a>
|
| 16 |
|
| 17 |
+
If `NDEBUG` is defined as a macro name at the point in the source file
|
| 18 |
+
where `<cassert>` is included, the `assert` macro is defined as
|
| 19 |
+
|
| 20 |
+
``` cpp
|
| 21 |
+
#define assert(...) ((void)0)
|
| 22 |
+
```
|
| 23 |
+
|
| 24 |
+
Otherwise, the `assert` macro puts a diagnostic test into programs; it
|
| 25 |
+
expands to an expression of type `void` which has the following effects:
|
| 26 |
+
|
| 27 |
+
- `__VA_ARGS__` is evaluated and contextually converted to `bool`.
|
| 28 |
+
- If the evaluation yields `true` there are no further effects.
|
| 29 |
+
- Otherwise, the `assert` macro’s expression creates a diagnostic on the
|
| 30 |
+
standard error stream (ISO/IEC 9899:2018 (C), 7.23.3) in an
|
| 31 |
+
*implementation-defined* format and calls `abort()`. The diagnostic
|
| 32 |
+
contains `#``__VA_ARGS__` and information on the name of the source
|
| 33 |
+
file, the source line number, and the name of the enclosing function
|
| 34 |
+
(such as provided by `source_location::current()`).
|
| 35 |
+
|
| 36 |
+
If `__VA_ARGS__` does not expand to an *assignment-expression*, the
|
| 37 |
+
program is ill-formed.
|
| 38 |
+
|
| 39 |
+
The macro `assert` is redefined according to the current state of
|
| 40 |
+
`NDEBUG` each time that `<cassert>` is included.
|
| 41 |
+
|
| 42 |
An expression `assert(E)` is a constant subexpression
|
| 43 |
[[defns.const.subexpr]], if
|
| 44 |
|
| 45 |
- `NDEBUG` is defined at the point where `assert` is last defined or
|
| 46 |
redefined, or
|