Skip to content

Commit e9ab30c

Browse files
committed
Update contracts.md to emphasize lazy evaluation and the default group
1 parent 9b6b9eb commit e9ab30c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

docs/cpp2/contracts.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ Cpp2 currently supports three kinds of contracts:
1111

1212
Notes:
1313

14-
- `condition` is an expression that evaluates to `#!cpp true` or `#!cpp false`.
14+
- `condition` is an expression that evaluates to `#!cpp true` or `#!cpp false`. It will not be evaluated unless checking for this contract group is enabled (`group.is_active()` is `true`).
1515

1616
- Optionally, `condition` may be followed by `, "message"`, a message to include if a violation occurs. For example, `pre(condition, "message")`.
1717

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)`. If no contract group is specified, the contract defaults to being part of the `cpp2_default` group.
1919

2020
The order of evaluation is:
2121

@@ -151,7 +151,7 @@ Cpp2 comes with five predefined `contract group` global objects in namespace `cp
151151

152152
For these groups, the default handler is `cpp2::report_and_terminate`, which prints information about the violation to `std::cerr` and then calls `std::terminate()`. But you can customize it to do anything you want, including to integrate with any third-party or in-house error reporting system your project is already using. For example:
153153

154-
``` cpp title="Example of customized contract violation handler" hl_lines="2 8-9 17"
154+
``` cpp title="Example of customized contract violation handler" hl_lines="2 8-10 17"
155155
main: () -> int = {
156156
cpp2::default.set_handler(call_my_framework&);
157157
assert<default>(false, "this is a test, this is only a test");

0 commit comments

Comments
 (0)