From Jason Turner

[support.exception]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp2_zmnh3w/{from.md → to.md} +33 -56
tmp/tmp2_zmnh3w/{from.md → to.md} RENAMED
@@ -27,12 +27,10 @@ namespace std {
27
  template<class T> [[noreturn]] void throw_with_nested(T&& t);
28
  template<class E> void rethrow_if_nested(const E& e);
29
  }
30
  ```
31
 
32
-   [[except.special]].
33
-
34
  ### Class `exception` <a id="exception">[[exception]]</a>
35
 
36
  ``` cpp
37
  namespace std {
38
  class exception {
@@ -48,33 +46,32 @@ namespace std {
48
 
49
  The class `exception` defines the base class for the types of objects
50
  thrown as exceptions by C++ standard library components, and certain
51
  expressions, to report errors detected during program execution.
52
 
53
- Each standard library class `T` that derives from class `exception`
54
- shall have a publicly accessible copy constructor and a publicly
55
- accessible copy assignment operator that do not exit with an exception.
56
- These member functions shall meet the following postcondition: If two
57
- objects `lhs` and `rhs` both have dynamic type `T` and `lhs` is a copy
58
- of `rhs`, then `strcmp(lhs.what(), rhs.what())` shall equal 0.
59
 
60
- ``` cpp
61
- exception() noexcept;
62
- ```
 
63
 
64
- *Effects:* Constructs an object of class `exception`.
 
 
 
 
65
 
66
  ``` cpp
67
  exception(const exception& rhs) noexcept;
68
  exception& operator=(const exception& rhs) noexcept;
69
  ```
70
 
71
- *Effects:* Copies an `exception` object.
72
-
73
- *Postconditions:* If `*this` and `rhs` both have dynamic type
74
- `exception` then the value of the expression
75
- `strcmp(what(), rhs.what())` shall equal 0.
76
 
77
  ``` cpp
78
  virtual ~exception();
79
  ```
80
 
@@ -85,58 +82,39 @@ virtual const char* what() const noexcept;
85
  ```
86
 
87
  *Returns:* An *implementation-defined* NTBS.
88
 
89
  *Remarks:* The message may be a null-terminated multibyte
90
- string ([[multibyte.strings]]), suitable for conversion and display as
91
- a `wstring` ([[string.classes]], [[locale.codecvt]]). The return value
92
  remains valid until the exception object from which it is obtained is
93
  destroyed or a non-`const` member function of the exception object is
94
  called.
95
 
96
  ### Class `bad_exception` <a id="bad.exception">[[bad.exception]]</a>
97
 
98
  ``` cpp
99
  namespace std {
100
  class bad_exception : public exception {
101
  public:
102
- bad_exception() noexcept;
103
- bad_exception(const bad_exception&) noexcept;
104
- bad_exception& operator=(const bad_exception&) noexcept;
105
  const char* what() const noexcept override;
106
  };
107
  }
108
  ```
109
 
110
  The class `bad_exception` defines the type of the object referenced by
111
- the `exception_ptr` returned from a call to `current_exception` (
112
- [[propagation]]) when the currently active exception object fails to
113
  copy.
114
 
115
- ``` cpp
116
- bad_exception() noexcept;
117
- ```
118
-
119
- *Effects:* Constructs an object of class `bad_exception`.
120
-
121
- ``` cpp
122
- bad_exception(const bad_exception&) noexcept;
123
- bad_exception& operator=(const bad_exception&) noexcept;
124
- ```
125
-
126
- *Effects:* Copies an object of class `bad_exception`.
127
-
128
  ``` cpp
129
  const char* what() const noexcept override;
130
  ```
131
 
132
  *Returns:* An *implementation-defined* NTBS.
133
 
134
- *Remarks:* The message may be a null-terminated multibyte
135
- string ([[multibyte.strings]]), suitable for conversion and display as
136
- a `wstring` ([[string.classes]], [[locale.codecvt]]).
137
-
138
  ### Abnormal termination <a id="exception.terminate">[[exception.terminate]]</a>
139
 
140
  #### Type `terminate_handler` <a id="terminate.handler">[[terminate.handler]]</a>
141
 
142
  ``` cpp
@@ -181,12 +159,12 @@ terminate_handler get_terminate() noexcept;
181
  ``` cpp
182
  [[noreturn]] void terminate() noexcept;
183
  ```
184
 
185
  *Remarks:* Called by the implementation when exception handling must be
186
- abandoned for any of several reasons ([[except.terminate]]). May also
187
- be called directly by the program.
188
 
189
  *Effects:* Calls a `terminate_handler` function. It is unspecified which
190
  `terminate_handler` function will be called if an exception is active
191
  during a call to `set_terminate`. Otherwise calls the current
192
  `terminate_handler` function.
@@ -198,26 +176,25 @@ callable handler in this context. — *end note*]
198
 
199
  ``` cpp
200
  int uncaught_exceptions() noexcept;
201
  ```
202
 
203
- *Returns:* The number of uncaught exceptions ([[except.uncaught]]).
204
 
205
  *Remarks:* When `uncaught_exceptions() > 0`, throwing an exception can
206
- result in a call of
207
- `std::terminate()` ([[except.terminate]]).
208
 
209
  ### Exception propagation <a id="propagation">[[propagation]]</a>
210
 
211
  ``` cpp
212
  using exception_ptr = unspecified;
213
  ```
214
 
215
  The type `exception_ptr` can be used to refer to an exception object.
216
 
217
- `exception_ptr` shall satisfy the requirements of
218
- `NullablePointer` ([[nullablepointer.requirements]]).
219
 
220
  Two non-null values of type `exception_ptr` are equivalent and compare
221
  equal if and only if they refer to the same exception.
222
 
223
  The default constructor of `exception_ptr` produces the null value of
@@ -244,14 +221,14 @@ introduce a data race. — *end note*]
244
  ``` cpp
245
  exception_ptr current_exception() noexcept;
246
  ```
247
 
248
  *Returns:* An `exception_ptr` object that refers to the currently
249
- handled exception ([[except.handle]]) or a copy of the currently
250
- handled exception, or a null `exception_ptr` object if no exception is
251
- being handled. The referenced object shall remain valid at least as long
252
- as there is an `exception_ptr` object that refers to it. If the function
253
  needs to allocate memory and the attempt fails, it returns an
254
  `exception_ptr` object that refers to an instance of `bad_alloc`. It is
255
  unspecified whether the return values of two successive calls to
256
  `current_exception` refer to the same exception object.
257
 
@@ -269,11 +246,11 @@ to avoid infinite recursion. — *end note*]
269
 
270
  ``` cpp
271
  [[noreturn]] void rethrow_exception(exception_ptr p);
272
  ```
273
 
274
- *Requires:* `p` shall not be a null pointer.
275
 
276
  *Throws:* The exception object to which `p` refers.
277
 
278
  ``` cpp
279
  template<class E> exception_ptr make_exception_ptr(E e) noexcept;
@@ -332,12 +309,12 @@ returned value.
332
  ``` cpp
333
  [[noreturn]] void rethrow_nested() const;
334
  ```
335
 
336
  *Effects:* If `nested_ptr()` returns a null pointer, the function calls
337
- `std::terminate()`. Otherwise, it throws the stored exception captured
338
- by `*this`.
339
 
340
  ``` cpp
341
  exception_ptr nested_ptr() const noexcept;
342
  ```
343
 
@@ -348,11 +325,11 @@ object.
348
  template<class T> [[noreturn]] void throw_with_nested(T&& t);
349
  ```
350
 
351
  Let `U` be `decay_t<T>`.
352
 
353
- *Requires:* `U` shall be `CopyConstructible`.
354
 
355
  *Throws:* If
356
  `is_class_v<U> && !is_final_v<U> && !is_base_of_v<nested_exception, U>`
357
  is `true`, an exception of unspecified type that is publicly derived
358
  from both `U` and `nested_exception` and constructed from
 
27
  template<class T> [[noreturn]] void throw_with_nested(T&& t);
28
  template<class E> void rethrow_if_nested(const E& e);
29
  }
30
  ```
31
 
 
 
32
  ### Class `exception` <a id="exception">[[exception]]</a>
33
 
34
  ``` cpp
35
  namespace std {
36
  class exception {
 
46
 
47
  The class `exception` defines the base class for the types of objects
48
  thrown as exceptions by C++ standard library components, and certain
49
  expressions, to report errors detected during program execution.
50
 
51
+ Each standard library class `T` that derives from class `exception` has
52
+ the following publicly accessible member functions, each of them having
53
+ a non-throwing exception specification [[except.spec]]:
 
 
 
54
 
55
+ - default constructor (unless the class synopsis shows other
56
+ constructors)
57
+ - copy constructor
58
+ - copy assignment operator
59
 
60
+ The copy constructor and the copy assignment operator meet the following
61
+ postcondition: If two objects `lhs` and `rhs` both have dynamic type `T`
62
+ and `lhs` is a copy of `rhs`, then `strcmp(lhs.what(), rhs.what())` is
63
+ equal to `0`. The `what()` member function of each such `T` satisfies
64
+ the constraints specified for `exception::what()` (see below).
65
 
66
  ``` cpp
67
  exception(const exception& rhs) noexcept;
68
  exception& operator=(const exception& rhs) noexcept;
69
  ```
70
 
71
+ *Ensures:* If `*this` and `rhs` both have dynamic type `exception` then
72
+ the value of the expression `strcmp(what(), rhs.what())` shall equal 0.
 
 
 
73
 
74
  ``` cpp
75
  virtual ~exception();
76
  ```
77
 
 
82
  ```
83
 
84
  *Returns:* An *implementation-defined* NTBS.
85
 
86
  *Remarks:* The message may be a null-terminated multibyte
87
+ string [[multibyte.strings]], suitable for conversion and display as a
88
+ `wstring` ([[string.classes]], [[locale.codecvt]]). The return value
89
  remains valid until the exception object from which it is obtained is
90
  destroyed or a non-`const` member function of the exception object is
91
  called.
92
 
93
  ### Class `bad_exception` <a id="bad.exception">[[bad.exception]]</a>
94
 
95
  ``` cpp
96
  namespace std {
97
  class bad_exception : public exception {
98
  public:
99
+ // see [exception] for the specification of the special member functions
 
 
100
  const char* what() const noexcept override;
101
  };
102
  }
103
  ```
104
 
105
  The class `bad_exception` defines the type of the object referenced by
106
+ the `exception_ptr` returned from a call to `current_exception`
107
+ [[propagation]] when the currently active exception object fails to
108
  copy.
109
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
  ``` cpp
111
  const char* what() const noexcept override;
112
  ```
113
 
114
  *Returns:* An *implementation-defined* NTBS.
115
 
 
 
 
 
116
  ### Abnormal termination <a id="exception.terminate">[[exception.terminate]]</a>
117
 
118
  #### Type `terminate_handler` <a id="terminate.handler">[[terminate.handler]]</a>
119
 
120
  ``` cpp
 
159
  ``` cpp
160
  [[noreturn]] void terminate() noexcept;
161
  ```
162
 
163
  *Remarks:* Called by the implementation when exception handling must be
164
+ abandoned for any of several reasons [[except.terminate]]. May also be
165
+ called directly by the program.
166
 
167
  *Effects:* Calls a `terminate_handler` function. It is unspecified which
168
  `terminate_handler` function will be called if an exception is active
169
  during a call to `set_terminate`. Otherwise calls the current
170
  `terminate_handler` function.
 
176
 
177
  ``` cpp
178
  int uncaught_exceptions() noexcept;
179
  ```
180
 
181
+ *Returns:* The number of uncaught exceptions [[except.uncaught]].
182
 
183
  *Remarks:* When `uncaught_exceptions() > 0`, throwing an exception can
184
+ result in a call of the function `std::terminate` [[except.terminate]].
 
185
 
186
  ### Exception propagation <a id="propagation">[[propagation]]</a>
187
 
188
  ``` cpp
189
  using exception_ptr = unspecified;
190
  ```
191
 
192
  The type `exception_ptr` can be used to refer to an exception object.
193
 
194
+ `exception_ptr` meets the requirements of *Cpp17NullablePointer*
195
+ ([[cpp17.nullablepointer]]).
196
 
197
  Two non-null values of type `exception_ptr` are equivalent and compare
198
  equal if and only if they refer to the same exception.
199
 
200
  The default constructor of `exception_ptr` produces the null value of
 
221
  ``` cpp
222
  exception_ptr current_exception() noexcept;
223
  ```
224
 
225
  *Returns:* An `exception_ptr` object that refers to the currently
226
+ handled exception [[except.handle]] or a copy of the currently handled
227
+ exception, or a null `exception_ptr` object if no exception is being
228
+ handled. The referenced object shall remain valid at least as long as
229
+ there is an `exception_ptr` object that refers to it. If the function
230
  needs to allocate memory and the attempt fails, it returns an
231
  `exception_ptr` object that refers to an instance of `bad_alloc`. It is
232
  unspecified whether the return values of two successive calls to
233
  `current_exception` refer to the same exception object.
234
 
 
246
 
247
  ``` cpp
248
  [[noreturn]] void rethrow_exception(exception_ptr p);
249
  ```
250
 
251
+ *Preconditions:* `p` is not a null pointer.
252
 
253
  *Throws:* The exception object to which `p` refers.
254
 
255
  ``` cpp
256
  template<class E> exception_ptr make_exception_ptr(E e) noexcept;
 
309
  ``` cpp
310
  [[noreturn]] void rethrow_nested() const;
311
  ```
312
 
313
  *Effects:* If `nested_ptr()` returns a null pointer, the function calls
314
+ the function `std::terminate`. Otherwise, it throws the stored exception
315
+ captured by `*this`.
316
 
317
  ``` cpp
318
  exception_ptr nested_ptr() const noexcept;
319
  ```
320
 
 
325
  template<class T> [[noreturn]] void throw_with_nested(T&& t);
326
  ```
327
 
328
  Let `U` be `decay_t<T>`.
329
 
330
+ *Preconditions:* `U` meets the *Cpp17CopyConstructible* requirements.
331
 
332
  *Throws:* If
333
  `is_class_v<U> && !is_final_v<U> && !is_base_of_v<nested_exception, U>`
334
  is `true`, an exception of unspecified type that is publicly derived
335
  from both `U` and `nested_exception` and constructed from