From Jason Turner

[support.contract]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpk59reolx/{from.md → to.md} +182 -0
tmp/tmpk59reolx/{from.md → to.md} RENAMED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Contract-violation handling <a id="support.contract">[[support.contract]]</a>
2
+
3
+ ### Header `<contracts>` synopsis <a id="contracts.syn">[[contracts.syn]]</a>
4
+
5
+ The header `<contracts>` defines types for reporting information about
6
+ contract violations [[basic.contract.eval]].
7
+
8
+ ``` cpp
9
+ // all freestanding
10
+ namespace std::contracts {
11
+
12
+ enum class assertion_kind : unspecified {
13
+ pre = 1,
14
+ post = 2,
15
+ assert = 3
16
+ };
17
+
18
+ enum class evaluation_semantic : unspecified {
19
+ ignore = 1,
20
+ observe = 2,
21
+ enforce = 3,
22
+ quick_enforce = 4
23
+ };
24
+
25
+ enum class detection_mode : unspecified {
26
+ predicate_false = 1,
27
+ evaluation_exception = 2
28
+ };
29
+
30
+ class contract_violation {
31
+ // no user-accessible constructor
32
+ public:
33
+ contract_violation(const contract_violation&) = delete;
34
+ contract_violation& operator=(const contract_violation&) = delete;
35
+
36
+ see below ~contract_violation();
37
+
38
+ const char* comment() const noexcept;
39
+ contracts::detection_mode detection_mode() const noexcept;
40
+ exception_ptr evaluation_exception() const noexcept;
41
+ bool is_terminating() const noexcept;
42
+ assertion_kind kind() const noexcept;
43
+ source_location location() const noexcept;
44
+ evaluation_semantic semantic() const noexcept;
45
+ };
46
+
47
+ void invoke_default_contract_violation_handler(const contract_violation&);
48
+ }
49
+ ```
50
+
51
+ ### Enumerations <a id="support.contract.enum">[[support.contract.enum]]</a>
52
+
53
+ *Recommended practice:* For all enumerations in
54
+ [[support.contract.enum]], if implementation-defined enumerators are
55
+ provided, they should have a minimum value of 1000.
56
+
57
+ The enumerators of `assertion_kind` correspond to the syntactic forms of
58
+ a contract assertion [[basic.contract.general]], with meanings listed in
59
+ Table  [[tab:support.contract.enum.kind]].
60
+
61
+ **Table: Enum `assertion_kind`** <a id="support.contract.enum.kind">[support.contract.enum.kind]</a>
62
+
63
+ | Name | Meaning |
64
+ | -------- | ------------------------- |
65
+ | `pre` | A precondition assertion |
66
+ | `post` | A postcondition assertion |
67
+ | `assert` | An *assertion-statement* |
68
+
69
+
70
+ The enumerators of `evaluation_semantic` correspond to the evaluation
71
+ semantics with which a contract assertion may be evaluated
72
+ [[basic.contract.eval]], with meanings listed in Table 
73
+ [[tab:support.contract.enum.semantic]].
74
+
75
+ **Table: Enum `evaluation_semantic`** <a id="support.contract.enum.semantic">[support.contract.enum.semantic]</a>
76
+
77
+ | Name | Meaning |
78
+ | --------------- | --------------------------------- |
79
+ | `ignore` | Ignore evaluation semantic |
80
+ | `observe` | Observe evaluation semantic |
81
+ | `enforce` | Enforce evaluation semantic |
82
+ | `quick_enforce` | Quick-enforce evaluation semantic |
83
+
84
+
85
+ The enumerators of `detection_mode` correspond to the manners in which a
86
+ contract violation can be identified [[basic.contract.eval]], with
87
+ meanings listed in Table~ [[tab:support.contract.enum.detection]].
88
+
89
+ **Table: Enum `detection_mode`** <a id="support.contract.enum.detection">[support.contract.enum.detection]</a>
90
+
91
+ | Name | Meaning |
92
+ | ---------------------- | ------------------------------------------------------------------------------------------------ |
93
+ | `predicate_false` | The predicate of the contract assertion evaluated to `false` or would have evaluated to `false`. |
94
+ | `evaluation_exception` | An uncaught exception occurred during evaluation of the contract assertion. |
95
+
96
+
97
+ ### Class `contract_violation` <a id="support.contract.violation">[[support.contract.violation]]</a>
98
+
99
+ The class `contract_violation` defines the type of objects used to
100
+ represent a contract violation that has been detected during the
101
+ evaluation of a contract assertion with a particular evaluation semantic
102
+ [[basic.contract.eval]]. Objects of this type can be created only by the
103
+ implementation. It is *implementation-defined* whether the destructor is
104
+ virtual.
105
+
106
+ ``` cpp
107
+ const char* comment() const noexcept;
108
+ ```
109
+
110
+ *Returns:* An *implementation-defined* NTMBS in the ordinary literal
111
+ encoding [[lex.charset]].
112
+
113
+ *Recommended practice:* The string returned should contain a textual
114
+ representation of the predicate of the violated contract assertion or an
115
+ empty string if storing a textual representation is undesired.
116
+
117
+ [*Note 1*: The string can represent a truncated, reformatted, or
118
+ summarized rendering of the predicate, before or after
119
+ preprocessing. — *end note*]
120
+
121
+ ``` cpp
122
+ contracts::detection_mode detection_mode() const noexcept;
123
+ ```
124
+
125
+ *Returns:* The enumerator value corresponding to the manner in which the
126
+ contract violation was identified.
127
+
128
+ ``` cpp
129
+ exception_ptr evaluation_exception() const noexcept;
130
+ ```
131
+
132
+ *Returns:* If the contract violation occurred because the evaluation of
133
+ the predicate exited via an exception, an `exception_ptr` object that
134
+ refers to that exception or a copy of that exception; otherwise, a null
135
+ `exception_ptr` object.
136
+
137
+ ``` cpp
138
+ bool is_terminating() const noexcept;
139
+ ```
140
+
141
+ *Returns:* `true` if the evaluation semantic is a terminating
142
+ semantic [[basic.contract.eval]]; otherwise, `false`.
143
+
144
+ ``` cpp
145
+ assertion_kind kind() const noexcept;
146
+ ```
147
+
148
+ *Returns:* The enumerator value corresponding to the syntactic form of
149
+ the violated contract assertion.
150
+
151
+ ``` cpp
152
+ source_location location() const noexcept;
153
+ ```
154
+
155
+ *Returns:* A `source_location` object with *implementation-defined*
156
+ value.
157
+
158
+ *Recommended practice:* The value returned should be a default
159
+ constructed `source_location` object or a value identifying the violated
160
+ contract assertion:
161
+
162
+ - When possible, if the violated contract assertion was a precondition,
163
+ the source location of the function invocation should be returned.
164
+ - Otherwise, the source location of the contract assertion should be
165
+ returned.
166
+
167
+ ``` cpp
168
+ evaluation_semantic semantic() const noexcept;
169
+ ```
170
+
171
+ *Returns:* The enumerator value corresponding to the evaluation semantic
172
+ with which the violated contract assertion was evaluated.
173
+
174
+ ### Invoke default handler <a id="support.contract.invoke">[[support.contract.invoke]]</a>
175
+
176
+ ``` cpp
177
+ void invoke_default_contract_violation_handler(const contract_violation& v);
178
+ ```
179
+
180
+ *Effects:* Invokes the default contract-violation
181
+ handler [[basic.contract.handler]] with the argument `v`.
182
+