tmp/tmp_avoof39/{from.md → to.md}
RENAMED
|
@@ -1,10 +1,10 @@
|
|
| 1 |
## Exception classes <a id="std.exceptions">[[std.exceptions]]</a>
|
| 2 |
|
| 3 |
The C++ standard library provides classes to be used to report certain
|
| 4 |
-
errors
|
| 5 |
-
|
| 6 |
categories: *logic* errors and *runtime* errors.
|
| 7 |
|
| 8 |
The distinguishing characteristic of logic errors is that they are due
|
| 9 |
to errors in the internal logic of the program. In theory, they are
|
| 10 |
preventable.
|
|
@@ -49,21 +49,17 @@ as violations of logical preconditions or class invariants.
|
|
| 49 |
|
| 50 |
``` cpp
|
| 51 |
logic_error(const string& what_arg);
|
| 52 |
```
|
| 53 |
|
| 54 |
-
*
|
| 55 |
-
|
| 56 |
-
*Postconditions:* `strcmp(what(), what_arg.c_str()) == 0`.
|
| 57 |
|
| 58 |
``` cpp
|
| 59 |
logic_error(const char* what_arg);
|
| 60 |
```
|
| 61 |
|
| 62 |
-
*
|
| 63 |
-
|
| 64 |
-
*Postconditions:* `strcmp(what(), what_arg) == 0`.
|
| 65 |
|
| 66 |
### Class `domain_error` <a id="domain.error">[[domain.error]]</a>
|
| 67 |
|
| 68 |
``` cpp
|
| 69 |
namespace std {
|
|
@@ -80,21 +76,17 @@ exceptions by the implementation to report domain errors.
|
|
| 80 |
|
| 81 |
``` cpp
|
| 82 |
domain_error(const string& what_arg);
|
| 83 |
```
|
| 84 |
|
| 85 |
-
*
|
| 86 |
-
|
| 87 |
-
*Postconditions:* `strcmp(what(), what_arg.c_str()) == 0`.
|
| 88 |
|
| 89 |
``` cpp
|
| 90 |
domain_error(const char* what_arg);
|
| 91 |
```
|
| 92 |
|
| 93 |
-
*
|
| 94 |
-
|
| 95 |
-
*Postconditions:* `strcmp(what(), what_arg) == 0`.
|
| 96 |
|
| 97 |
### Class `invalid_argument` <a id="invalid.argument">[[invalid.argument]]</a>
|
| 98 |
|
| 99 |
``` cpp
|
| 100 |
namespace std {
|
|
@@ -111,21 +103,17 @@ exceptions to report an invalid argument.
|
|
| 111 |
|
| 112 |
``` cpp
|
| 113 |
invalid_argument(const string& what_arg);
|
| 114 |
```
|
| 115 |
|
| 116 |
-
*
|
| 117 |
-
|
| 118 |
-
*Postconditions:* `strcmp(what(), what_arg.c_str()) == 0`.
|
| 119 |
|
| 120 |
``` cpp
|
| 121 |
invalid_argument(const char* what_arg);
|
| 122 |
```
|
| 123 |
|
| 124 |
-
*
|
| 125 |
-
|
| 126 |
-
*Postconditions:* `strcmp(what(), what_arg) == 0`.
|
| 127 |
|
| 128 |
### Class `length_error` <a id="length.error">[[length.error]]</a>
|
| 129 |
|
| 130 |
``` cpp
|
| 131 |
namespace std {
|
|
@@ -143,21 +131,17 @@ exceeds its maximum allowable size.
|
|
| 143 |
|
| 144 |
``` cpp
|
| 145 |
length_error(const string& what_arg);
|
| 146 |
```
|
| 147 |
|
| 148 |
-
*
|
| 149 |
-
|
| 150 |
-
*Postconditions:* `strcmp(what(), what_arg.c_str()) == 0`.
|
| 151 |
|
| 152 |
``` cpp
|
| 153 |
length_error(const char* what_arg);
|
| 154 |
```
|
| 155 |
|
| 156 |
-
*
|
| 157 |
-
|
| 158 |
-
*Postconditions:* `strcmp(what(), what_arg) == 0`.
|
| 159 |
|
| 160 |
### Class `out_of_range` <a id="out.of.range">[[out.of.range]]</a>
|
| 161 |
|
| 162 |
``` cpp
|
| 163 |
namespace std {
|
|
@@ -174,21 +158,17 @@ exceptions to report an argument value not in its expected range.
|
|
| 174 |
|
| 175 |
``` cpp
|
| 176 |
out_of_range(const string& what_arg);
|
| 177 |
```
|
| 178 |
|
| 179 |
-
*
|
| 180 |
-
|
| 181 |
-
*Postconditions:* `strcmp(what(), what_arg.c_str()) == 0`.
|
| 182 |
|
| 183 |
``` cpp
|
| 184 |
out_of_range(const char* what_arg);
|
| 185 |
```
|
| 186 |
|
| 187 |
-
*
|
| 188 |
-
|
| 189 |
-
*Postconditions:* `strcmp(what(), what_arg) == 0`.
|
| 190 |
|
| 191 |
### Class `runtime_error` <a id="runtime.error">[[runtime.error]]</a>
|
| 192 |
|
| 193 |
``` cpp
|
| 194 |
namespace std {
|
|
@@ -206,21 +186,17 @@ executes.
|
|
| 206 |
|
| 207 |
``` cpp
|
| 208 |
runtime_error(const string& what_arg);
|
| 209 |
```
|
| 210 |
|
| 211 |
-
*
|
| 212 |
-
|
| 213 |
-
*Postconditions:* `strcmp(what(), what_arg.c_str()) == 0`.
|
| 214 |
|
| 215 |
``` cpp
|
| 216 |
runtime_error(const char* what_arg);
|
| 217 |
```
|
| 218 |
|
| 219 |
-
*
|
| 220 |
-
|
| 221 |
-
*Postconditions:* `strcmp(what(), what_arg) == 0`.
|
| 222 |
|
| 223 |
### Class `range_error` <a id="range.error">[[range.error]]</a>
|
| 224 |
|
| 225 |
``` cpp
|
| 226 |
namespace std {
|
|
@@ -237,21 +213,17 @@ to report range errors in internal computations.
|
|
| 237 |
|
| 238 |
``` cpp
|
| 239 |
range_error(const string& what_arg);
|
| 240 |
```
|
| 241 |
|
| 242 |
-
*
|
| 243 |
-
|
| 244 |
-
*Postconditions:* `strcmp(what(), what_arg.c_str()) == 0`.
|
| 245 |
|
| 246 |
``` cpp
|
| 247 |
range_error(const char* what_arg);
|
| 248 |
```
|
| 249 |
|
| 250 |
-
*
|
| 251 |
-
|
| 252 |
-
*Postconditions:* `strcmp(what(), what_arg) == 0`.
|
| 253 |
|
| 254 |
### Class `overflow_error` <a id="overflow.error">[[overflow.error]]</a>
|
| 255 |
|
| 256 |
``` cpp
|
| 257 |
namespace std {
|
|
@@ -268,21 +240,17 @@ exceptions to report an arithmetic overflow error.
|
|
| 268 |
|
| 269 |
``` cpp
|
| 270 |
overflow_error(const string& what_arg);
|
| 271 |
```
|
| 272 |
|
| 273 |
-
*
|
| 274 |
-
|
| 275 |
-
*Postconditions:* `strcmp(what(), what_arg.c_str()) == 0`.
|
| 276 |
|
| 277 |
``` cpp
|
| 278 |
overflow_error(const char* what_arg);
|
| 279 |
```
|
| 280 |
|
| 281 |
-
*
|
| 282 |
-
|
| 283 |
-
*Postconditions:* `strcmp(what(), what_arg) == 0`.
|
| 284 |
|
| 285 |
### Class `underflow_error` <a id="underflow.error">[[underflow.error]]</a>
|
| 286 |
|
| 287 |
``` cpp
|
| 288 |
namespace std {
|
|
@@ -299,17 +267,13 @@ exceptions to report an arithmetic underflow error.
|
|
| 299 |
|
| 300 |
``` cpp
|
| 301 |
underflow_error(const string& what_arg);
|
| 302 |
```
|
| 303 |
|
| 304 |
-
*
|
| 305 |
-
|
| 306 |
-
*Postconditions:* `strcmp(what(), what_arg.c_str()) == 0`.
|
| 307 |
|
| 308 |
``` cpp
|
| 309 |
underflow_error(const char* what_arg);
|
| 310 |
```
|
| 311 |
|
| 312 |
-
*
|
| 313 |
-
|
| 314 |
-
*Postconditions:* `strcmp(what(), what_arg) == 0`.
|
| 315 |
|
|
|
|
| 1 |
## Exception classes <a id="std.exceptions">[[std.exceptions]]</a>
|
| 2 |
|
| 3 |
The C++ standard library provides classes to be used to report certain
|
| 4 |
+
errors [[res.on.exception.handling]] in C++ programs. In the error model
|
| 5 |
+
reflected in these classes, errors are divided into two broad
|
| 6 |
categories: *logic* errors and *runtime* errors.
|
| 7 |
|
| 8 |
The distinguishing characteristic of logic errors is that they are due
|
| 9 |
to errors in the internal logic of the program. In theory, they are
|
| 10 |
preventable.
|
|
|
|
| 49 |
|
| 50 |
``` cpp
|
| 51 |
logic_error(const string& what_arg);
|
| 52 |
```
|
| 53 |
|
| 54 |
+
*Ensures:* `strcmp(what(), what_arg.c_str()) == 0`.
|
|
|
|
|
|
|
| 55 |
|
| 56 |
``` cpp
|
| 57 |
logic_error(const char* what_arg);
|
| 58 |
```
|
| 59 |
|
| 60 |
+
*Ensures:* `strcmp(what(), what_arg) == 0`.
|
|
|
|
|
|
|
| 61 |
|
| 62 |
### Class `domain_error` <a id="domain.error">[[domain.error]]</a>
|
| 63 |
|
| 64 |
``` cpp
|
| 65 |
namespace std {
|
|
|
|
| 76 |
|
| 77 |
``` cpp
|
| 78 |
domain_error(const string& what_arg);
|
| 79 |
```
|
| 80 |
|
| 81 |
+
*Ensures:* `strcmp(what(), what_arg.c_str()) == 0`.
|
|
|
|
|
|
|
| 82 |
|
| 83 |
``` cpp
|
| 84 |
domain_error(const char* what_arg);
|
| 85 |
```
|
| 86 |
|
| 87 |
+
*Ensures:* `strcmp(what(), what_arg) == 0`.
|
|
|
|
|
|
|
| 88 |
|
| 89 |
### Class `invalid_argument` <a id="invalid.argument">[[invalid.argument]]</a>
|
| 90 |
|
| 91 |
``` cpp
|
| 92 |
namespace std {
|
|
|
|
| 103 |
|
| 104 |
``` cpp
|
| 105 |
invalid_argument(const string& what_arg);
|
| 106 |
```
|
| 107 |
|
| 108 |
+
*Ensures:* `strcmp(what(), what_arg.c_str()) == 0`.
|
|
|
|
|
|
|
| 109 |
|
| 110 |
``` cpp
|
| 111 |
invalid_argument(const char* what_arg);
|
| 112 |
```
|
| 113 |
|
| 114 |
+
*Ensures:* `strcmp(what(), what_arg) == 0`.
|
|
|
|
|
|
|
| 115 |
|
| 116 |
### Class `length_error` <a id="length.error">[[length.error]]</a>
|
| 117 |
|
| 118 |
``` cpp
|
| 119 |
namespace std {
|
|
|
|
| 131 |
|
| 132 |
``` cpp
|
| 133 |
length_error(const string& what_arg);
|
| 134 |
```
|
| 135 |
|
| 136 |
+
*Ensures:* `strcmp(what(), what_arg.c_str()) == 0`.
|
|
|
|
|
|
|
| 137 |
|
| 138 |
``` cpp
|
| 139 |
length_error(const char* what_arg);
|
| 140 |
```
|
| 141 |
|
| 142 |
+
*Ensures:* `strcmp(what(), what_arg) == 0`.
|
|
|
|
|
|
|
| 143 |
|
| 144 |
### Class `out_of_range` <a id="out.of.range">[[out.of.range]]</a>
|
| 145 |
|
| 146 |
``` cpp
|
| 147 |
namespace std {
|
|
|
|
| 158 |
|
| 159 |
``` cpp
|
| 160 |
out_of_range(const string& what_arg);
|
| 161 |
```
|
| 162 |
|
| 163 |
+
*Ensures:* `strcmp(what(), what_arg.c_str()) == 0`.
|
|
|
|
|
|
|
| 164 |
|
| 165 |
``` cpp
|
| 166 |
out_of_range(const char* what_arg);
|
| 167 |
```
|
| 168 |
|
| 169 |
+
*Ensures:* `strcmp(what(), what_arg) == 0`.
|
|
|
|
|
|
|
| 170 |
|
| 171 |
### Class `runtime_error` <a id="runtime.error">[[runtime.error]]</a>
|
| 172 |
|
| 173 |
``` cpp
|
| 174 |
namespace std {
|
|
|
|
| 186 |
|
| 187 |
``` cpp
|
| 188 |
runtime_error(const string& what_arg);
|
| 189 |
```
|
| 190 |
|
| 191 |
+
*Ensures:* `strcmp(what(), what_arg.c_str()) == 0`.
|
|
|
|
|
|
|
| 192 |
|
| 193 |
``` cpp
|
| 194 |
runtime_error(const char* what_arg);
|
| 195 |
```
|
| 196 |
|
| 197 |
+
*Ensures:* `strcmp(what(), what_arg) == 0`.
|
|
|
|
|
|
|
| 198 |
|
| 199 |
### Class `range_error` <a id="range.error">[[range.error]]</a>
|
| 200 |
|
| 201 |
``` cpp
|
| 202 |
namespace std {
|
|
|
|
| 213 |
|
| 214 |
``` cpp
|
| 215 |
range_error(const string& what_arg);
|
| 216 |
```
|
| 217 |
|
| 218 |
+
*Ensures:* `strcmp(what(), what_arg.c_str()) == 0`.
|
|
|
|
|
|
|
| 219 |
|
| 220 |
``` cpp
|
| 221 |
range_error(const char* what_arg);
|
| 222 |
```
|
| 223 |
|
| 224 |
+
*Ensures:* `strcmp(what(), what_arg) == 0`.
|
|
|
|
|
|
|
| 225 |
|
| 226 |
### Class `overflow_error` <a id="overflow.error">[[overflow.error]]</a>
|
| 227 |
|
| 228 |
``` cpp
|
| 229 |
namespace std {
|
|
|
|
| 240 |
|
| 241 |
``` cpp
|
| 242 |
overflow_error(const string& what_arg);
|
| 243 |
```
|
| 244 |
|
| 245 |
+
*Ensures:* `strcmp(what(), what_arg.c_str()) == 0`.
|
|
|
|
|
|
|
| 246 |
|
| 247 |
``` cpp
|
| 248 |
overflow_error(const char* what_arg);
|
| 249 |
```
|
| 250 |
|
| 251 |
+
*Ensures:* `strcmp(what(), what_arg) == 0`.
|
|
|
|
|
|
|
| 252 |
|
| 253 |
### Class `underflow_error` <a id="underflow.error">[[underflow.error]]</a>
|
| 254 |
|
| 255 |
``` cpp
|
| 256 |
namespace std {
|
|
|
|
| 267 |
|
| 268 |
``` cpp
|
| 269 |
underflow_error(const string& what_arg);
|
| 270 |
```
|
| 271 |
|
| 272 |
+
*Ensures:* `strcmp(what(), what_arg.c_str()) == 0`.
|
|
|
|
|
|
|
| 273 |
|
| 274 |
``` cpp
|
| 275 |
underflow_error(const char* what_arg);
|
| 276 |
```
|
| 277 |
|
| 278 |
+
*Ensures:* `strcmp(what(), what_arg) == 0`.
|
|
|
|
|
|
|
| 279 |
|