6
Basics
[basic]
6.10
Contract assertions
[basic.contract]
6.10.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 by
precondition-specifier
s
,
postcondition-specifier
s
(
[dcl.
contract.
func]
), and
assertion-statement
s
(
[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-expression
s
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
]