8
Statements
[stmt]
8.8
Assertion statement
[stmt.contract.assert]
assertion-statement
:
contract_assert
attribute-specifier-seq
o
p
t
(
conditional-expression
)
;
1
#
An
assertion-statement
introduces a contract assertion (
[basic.
contract]
)
.
The optional
attribute-specifier-seq
appertains to the introduced contract assertion
.
2
#
The predicate (
[basic.
contract.
general]
) of an
assertion-statement
is its
conditional-expression
contextually converted to
bool
.
3
#
The evaluation of consecutive
assertion-statement
s
is an evaluation in sequence (
[basic.
contract.
eval]
) of the contract assertions introduced by those
assertion-statement
s
.
[
Note
1
:
A sequence of
assertion-statement
s
can thus be repeatedly evaluated as a group
.
[
Example
1
:
int
f
(
int
i
)
{
contract_assert
(
i
=
=
0
)
;
// #1
contract_assert
(
i
>
=
0
)
;
// #2
return
0
;
}
int
g
=
f
(
0
)
;
// can evaluate #1, #2, #1, #2
—
end example
]
—
end note
]