Files
2025-10-25 03:02:53 +03:00

2.6 KiB

[basic.contract.general]

6 Basics [basic]

6.11 Contract assertions [basic.contract]

6.11.1 General [basic.contract.general]

1

#

Contract assertions allow the programmer to specify properties of the state of the program that are expected to hold at certain points during execution.

Contract assertions are introduced byprecondition-specifiers,postcondition-specifiers ([dcl.contract.func]), andassertion-statements ([stmt.contract.assert]).

2

#

Each contract assertion has a contract-assertion predicate, which is an expression of type bool.

[Note 1:

The value of the predicate is used to identify program states that are expected.

— end note]

3

#

An invocation of the macro va_start ([cstdarg.syn]) shall not be a subexpression of the predicate of a contract assertion, no diagnostic required.

4

#

[Note 2:

Within the predicate of a contract assertion,id-expressions referring to variables declared outside the contract assertion are const ([expr.prim.id.unqual]),this is a pointer to const ([expr.prim.this]), and the result object can be named if a result-name-introducer ([dcl.contract.res]) has been specified.

— end note]