From Jason Turner

[except.spec]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp7r2cl92p/{from.md → to.md} +49 -18
tmp/tmp7r2cl92p/{from.md → to.md} RENAMED
@@ -28,11 +28,13 @@ noexcept-specification:
28
  ```
29
 
30
  In a *noexcept-specification*, the *constant-expression*, if supplied,
31
  shall be a constant expression ([[expr.const]]) that is contextually
32
  converted to `bool` (Clause  [[conv]]). A *noexcept-specification*
33
- `noexcept` is equivalent to `noexcept({}true)`.
 
 
34
 
35
  An *exception-specification* shall appear only on a function declarator
36
  for a function type, pointer to function type, reference to function
37
  type, or pointer to member function type that is the top-level type of a
38
  declaration or definition, or on such a type appearing as a parameter or
@@ -45,16 +47,16 @@ void (*fp)() throw (int); // OK
45
  void g(void pfa() throw(int)); // OK
46
  typedef int (*pf)() throw(int); // ill-formed
47
  ```
48
 
49
  A type denoted in an *exception-specification* shall not denote an
50
- incomplete type. A type denoted in an *exception-specification* shall
51
- not denote a pointer or reference to an incomplete type, other than
52
- `void*`, `const` `void*`, `volatile` `void*`, or `const` `volatile`
53
- `void*`. A type cv `T`, array of `T`”, or “function returning `T`”
54
- denoted in an *exception-specification* is adjusted to type `T`,
55
- “pointer to `T`”, or “pointer to function returning `T`”, respectively.
56
 
57
  Two *exception-specification*s are *compatible* if:
58
 
59
  - both are non-throwing (see below), regardless of their form,
60
  - both have the form `noexcept(`*constant-expression*`)` and the
@@ -188,37 +190,42 @@ yields `true`. A function with a non-throwing *exception-specification*
188
  does not allow any exceptions.
189
 
190
  An *exception-specification* is not considered part of a function’s
191
  type.
192
 
193
- An implicitly declared special member function (Clause  [[special]])
194
- shall have an *exception-specification*. If `f` is an implicitly
195
- declared default constructor, copy constructor, move constructor,
196
- destructor, copy assignment operator, or move assignment operator, its
197
- implicit *exception-specification* specifies the *type-id* `T` if and
198
- only if `T` is allowed by the *exception-specification* of a function
199
- directly invoked by `f`’s implicit definition; `f` shall allow all
 
200
  exceptions if any function it directly invokes allows all exceptions,
201
- and `f` shall allow no exceptions if every function it directly invokes
202
- allows no exceptions.
 
 
 
 
203
 
204
  ``` cpp
205
  struct A {
206
  A();
207
  A(const A&) throw();
208
  A(A&&) throw();
209
  ~A() throw(X);
210
  };
211
  struct B {
212
  B() throw();
213
- B(const B&) throw();
214
  B(B&&) throw(Y);
215
  ~B() throw(Y);
216
  };
217
  struct D : public A, public B {
218
  // Implicit declaration of D::D();
219
- // Implicit declaration of D::D(const D&) throw();
220
  // Implicit declaration of D::D(D&&) throw(Y);
221
  // Implicit declaration of D::~D() throw(X, Y);
222
  };
223
  ```
224
 
@@ -230,10 +237,34 @@ restrictive as that in the base class.
230
 
231
  A deallocation function ([[basic.stc.dynamic.deallocation]]) with no
232
  explicit *exception-specification* is treated as if it were specified
233
  with `noexcept(true)`.
234
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
235
  In a *dynamic-exception-specification*, a *type-id* followed by an
236
  ellipsis is a pack expansion ([[temp.variadic]]).
237
 
238
  The use of *dynamic-exception-specification*s is deprecated (see Annex 
239
  [[depr]]).
 
28
  ```
29
 
30
  In a *noexcept-specification*, the *constant-expression*, if supplied,
31
  shall be a constant expression ([[expr.const]]) that is contextually
32
  converted to `bool` (Clause  [[conv]]). A *noexcept-specification*
33
+ `noexcept` is equivalent to `noexcept(true)`. A `(` token that follows
34
+ `noexcept` is part of the *noexcept-specification* and does not commence
35
+ an initializer ([[dcl.init]]).
36
 
37
  An *exception-specification* shall appear only on a function declarator
38
  for a function type, pointer to function type, reference to function
39
  type, or pointer to member function type that is the top-level type of a
40
  declaration or definition, or on such a type appearing as a parameter or
 
47
  void g(void pfa() throw(int)); // OK
48
  typedef int (*pf)() throw(int); // ill-formed
49
  ```
50
 
51
  A type denoted in an *exception-specification* shall not denote an
52
+ incomplete type or an rvalue reference type. A type denoted in an
53
+ *exception-specification* shall not denote a pointer or reference to an
54
+ incomplete type, other than *cv* `void*`. A type cv `T`, “array of `T`”,
55
+ orfunction returning `T`” denoted in an *exception-specification* is
56
+ adjusted to type `T`, “pointer to `T`, or “pointer to function
57
+ returning `T`”, respectively.
58
 
59
  Two *exception-specification*s are *compatible* if:
60
 
61
  - both are non-throwing (see below), regardless of their form,
62
  - both have the form `noexcept(`*constant-expression*`)` and the
 
190
  does not allow any exceptions.
191
 
192
  An *exception-specification* is not considered part of a function’s
193
  type.
194
 
195
+ An inheriting constructor ([[class.inhctor]]) and an implicitly
196
+ declared special member function (Clause  [[special]]) have an
197
+ *exception-specification*. If `f` is an inheriting constructor or an
198
+ implicitly declared default constructor, copy constructor, move
199
+ constructor, destructor, copy assignment operator, or move assignment
200
+ operator, its implicit *exception-specification* specifies the *type-id*
201
+ `T` if and only if `T` is allowed by the *exception-specification* of a
202
+ function directly invoked by `f`’s implicit definition; `f` allows all
203
  exceptions if any function it directly invokes allows all exceptions,
204
+ and `f` has the *exception-specification* `noexcept(true)` if every
205
+ function it directly invokes allows no exceptions. It follows that `f`
206
+ has the *exception-specification* `noexcept(true)` if it invokes no
207
+ other functions. An instantiation of an inheriting constructor template
208
+ has an implied *exception-specification* as if it were a non-template
209
+ inheriting constructor.
210
 
211
  ``` cpp
212
  struct A {
213
  A();
214
  A(const A&) throw();
215
  A(A&&) throw();
216
  ~A() throw(X);
217
  };
218
  struct B {
219
  B() throw();
220
+ B(const B&) = default; // Declaration of B::B(const B&) noexcept(true)
221
  B(B&&) throw(Y);
222
  ~B() throw(Y);
223
  };
224
  struct D : public A, public B {
225
  // Implicit declaration of D::D();
226
+ // Implicit declaration of D::D(const D&) noexcept(true);
227
  // Implicit declaration of D::D(D&&) throw(Y);
228
  // Implicit declaration of D::~D() throw(X, Y);
229
  };
230
  ```
231
 
 
237
 
238
  A deallocation function ([[basic.stc.dynamic.deallocation]]) with no
239
  explicit *exception-specification* is treated as if it were specified
240
  with `noexcept(true)`.
241
 
242
+ An *exception-specification* is considered to be *needed* when:
243
+
244
+ - in an expression, the function is the unique lookup result or the
245
+ selected member of a set of overloaded functions ([[basic.lookup]],
246
+ [[over.match]], [[over.over]]);
247
+ - the function is odr-used ([[basic.def.odr]]) or, if it appears in an
248
+ unevaluated operand, would be odr-used if the expression were
249
+ potentially-evaluated;
250
+ - the *exception-specification* is compared to that of another
251
+ declaration (e.g., an explicit specialization or an overriding virtual
252
+ function);
253
+ - the function is defined; or
254
+ - the *exception-specification* is needed for a defaulted special member
255
+ function that calls the function. A defaulted declaration does not
256
+ require the *exception-specification* of a base member function to be
257
+ evaluated until the implicit *exception-specification* of the derived
258
+ function is needed, but an explicit *exception-specification* needs
259
+ the implicit *exception-specification* to compare against.
260
+
261
+ The *exception-specification* of a defaulted special member function is
262
+ evaluated as described above only when needed; similarly, the
263
+ *exception-specification* of a specialization of a function template or
264
+ member function of a class template is instantiated only when needed.
265
+
266
  In a *dynamic-exception-specification*, a *type-id* followed by an
267
  ellipsis is a pack expansion ([[temp.variadic]]).
268
 
269
  The use of *dynamic-exception-specification*s is deprecated (see Annex 
270
  [[depr]]).