From Jason Turner

[except.nested]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp1ykvqakj/{from.md → to.md} +16 -9
tmp/tmp1ykvqakj/{from.md → to.md} RENAMED
@@ -21,12 +21,13 @@ namespace std {
21
 
22
  The class `nested_exception` is designed for use as a mixin through
23
  multiple inheritance. It captures the currently handled exception and
24
  stores it for later use.
25
 
26
- `nested_exception` has a virtual destructor to make it a polymorphic
27
- class. Its presence can be tested for with `dynamic_cast`.
 
28
 
29
  ``` cpp
30
  nested_exception() noexcept;
31
  ```
32
 
@@ -50,22 +51,28 @@ object.
50
 
51
  ``` cpp
52
  template <class T> [[noreturn]] void throw_with_nested(T&& t);
53
  ```
54
 
55
- Let `U` be `remove_reference_t<T>`.
56
 
57
  *Requires:* `U` shall be `CopyConstructible`.
58
 
59
- *Throws:* if `U` is a non-union class type not derived from
60
- `nested_exception`, an exception of unspecified type that is publicly
61
- derived from both `U` and `nested_exception` and constructed from
 
62
  `std::forward<T>(t)`, otherwise `std::forward<T>(t)`.
63
 
64
  ``` cpp
65
  template <class E> void rethrow_if_nested(const E& e);
66
  ```
67
 
68
- *Effects:* If the dynamic type of `e` is publicly and unambiguously
69
- derived from `nested_exception`, calls `dynamic_cast<const`
70
- `nested_exception&>(e).rethrow_nested()`.
 
 
 
 
 
71
 
 
21
 
22
  The class `nested_exception` is designed for use as a mixin through
23
  multiple inheritance. It captures the currently handled exception and
24
  stores it for later use.
25
 
26
+ [*Note 1*: `nested_exception` has a virtual destructor to make it a
27
+ polymorphic class. Its presence can be tested for with
28
+ `dynamic_cast`. — *end note*]
29
 
30
  ``` cpp
31
  nested_exception() noexcept;
32
  ```
33
 
 
51
 
52
  ``` cpp
53
  template <class T> [[noreturn]] void throw_with_nested(T&& t);
54
  ```
55
 
56
+ Let `U` be `decay_t<T>`.
57
 
58
  *Requires:* `U` shall be `CopyConstructible`.
59
 
60
+ *Throws:* If
61
+ `is_class_v<U> && !is_final_v<U> && !is_base_of_v<nested_exception, U>`
62
+ is `true`, an exception of unspecified type that is publicly derived
63
+ from both `U` and `nested_exception` and constructed from
64
  `std::forward<T>(t)`, otherwise `std::forward<T>(t)`.
65
 
66
  ``` cpp
67
  template <class E> void rethrow_if_nested(const E& e);
68
  ```
69
 
70
+ *Effects:* If `E` is not a polymorphic class type, or if
71
+ `nested_exception` is an inaccessible or ambiguous base class of `E`,
72
+ there is no effect. Otherwise, performs:
73
+
74
+ ``` cpp
75
+ if (auto p = dynamic_cast<const nested_exception*>(addressof(e)))
76
+ p->rethrow_nested();
77
+ ```
78