You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/cpp2/contracts.md
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ Notes:
15
15
16
16
- Optionally, `condition` may be followed by `, "message"`, a message to include if a violation occurs. For example, `pre(condition, "message")`.
17
17
18
-
- Optionally, a `<group, pred1, pred2>` can be written inside `<``>` angle brackets immediately before the `(`, to designate that this test is part of the [contract group](#groups) named `group` and (also optionally) [contract predicates](#predicates)`pred1` and `pred2. If a violation occurs, `Group.report_violation()` will be called. For example, `pre<group>(condition)`.
18
+
- Optionally, a `<group, pred1, pred2>` can be written inside `<``>` angle brackets immediately before the `(`, to designate that this test is part of the [contract group](#groups) named `group` and (also optionally) [contract predicates](#predicates)`pred1` and `pred2`. If a violation occurs, `Group.report_violation()` will be called. For example, `pre<group>(condition)`.
19
19
20
20
The order of evaluation is:
21
21
@@ -31,7 +31,7 @@ For example:
31
31
32
32
```cpp title="Precondition and postcondition examples" hl_lines="2 3"
33
33
insert_at: (container, where: int, val: int)
34
-
pre<Bounds>( 0 <= where <= container.ssize(), "position (where)$ is outside 'container'" )
34
+
pre<bounds_safety>( 0 <= where <= container.ssize(), "position (where)$ is outside 'container'" )
35
35
post ( container.ssize() == container.ssize()$ + 1 )
36
36
= {
37
37
_ = container.insert( container.begin()+where, val );
@@ -42,9 +42,9 @@ In this example:
42
42
43
43
- The `$` captures are performed before entering the function.
44
44
45
-
- The precondition is part of the `Bounds` safety contract group and is checked before entering the function. If the check fails, say because `where` is `#!cpp -1`, then `#!cpp cpp2::Bounds.report_violation("position -1 is outside 'container'")` is called.
45
+
- The precondition is part of the `bounds_safety` contract group and is checked before entering the function. If the check fails, say because `where` is `#!cpp -1`, then `#!cpp cpp2::bounds_safety.report_violation("position -1 is outside 'container'")` is called.
46
46
47
-
- The postcondition is part of the `Default` safety contract group. If the check fails, then `#!cpp cpp2::Default.report_violation()` is called.
47
+
- The postcondition is part of the `default` safety contract group. If the check fails, then `#!cpp cpp2::default.report_violation()` is called.
0 commit comments