From Jason Turner

[expr.dynamic.cast]

Diff to HTML by rtfpessoa

tmp/tmpbb_dnqlj/{from.md → to.md} RENAMED
@@ -24,11 +24,11 @@ result is the null pointer value of type `T`.
24
  If `T` is “pointer to *cv1* `B`” and `v` has type “pointer to *cv2* `D`”
25
  such that `B` is a base class of `D`, the result is a pointer to the
26
  unique `B` subobject of the `D` object pointed to by `v`. Similarly, if
27
  `T` is “reference to *cv1* `B`” and `v` has type *cv2* `D` such that `B`
28
  is a base class of `D`, the result is the unique `B` subobject of the
29
- `D` object referred to by `v`. [^9] The result is an lvalue if `T` is an
30
  lvalue reference, or an xvalue if `T` is an rvalue reference. In both
31
  the pointer and reference cases, the program is ill-formed if *cv2* has
32
  greater cv-qualification than *cv1* or if `B` is an inaccessible or
33
  ambiguous base class of `D`.
34
 
@@ -38,11 +38,11 @@ struct D : B { };
38
  void foo(D* dp) {
39
  B* bp = dynamic_cast<B*>(dp); // equivalent to B* bp = dp;
40
  }
41
  ```
42
 
43
- Otherwise, `v` shall be a pointer to or an lvalue of a polymorphic
44
  type ([[class.virtual]]).
45
 
46
  If `T` is “pointer to *cv* `void`,” then the result is a pointer to the
47
  most derived object pointed to by `v`. Otherwise, a run-time check is
48
  applied to see if the object pointed or referred to by `v` can be
@@ -62,12 +62,13 @@ check logically executes as follows:
62
  result points (refers) to the `C` subobject of the most derived
63
  object.
64
  - Otherwise, the run-time check *fails*.
65
 
66
  The value of a failed cast to pointer type is the null pointer value of
67
- the required result type. A failed cast to reference type throws
68
- `std::bad_cast` ([[bad.cast]]).
 
69
 
70
  ``` cpp
71
  class A { virtual void f(); };
72
  class B { virtual void g(); };
73
  class D : public virtual A, private B { };
 
24
  If `T` is “pointer to *cv1* `B`” and `v` has type “pointer to *cv2* `D`”
25
  such that `B` is a base class of `D`, the result is a pointer to the
26
  unique `B` subobject of the `D` object pointed to by `v`. Similarly, if
27
  `T` is “reference to *cv1* `B`” and `v` has type *cv2* `D` such that `B`
28
  is a base class of `D`, the result is the unique `B` subobject of the
29
+ `D` object referred to by `v`. [^8] The result is an lvalue if `T` is an
30
  lvalue reference, or an xvalue if `T` is an rvalue reference. In both
31
  the pointer and reference cases, the program is ill-formed if *cv2* has
32
  greater cv-qualification than *cv1* or if `B` is an inaccessible or
33
  ambiguous base class of `D`.
34
 
 
38
  void foo(D* dp) {
39
  B* bp = dynamic_cast<B*>(dp); // equivalent to B* bp = dp;
40
  }
41
  ```
42
 
43
+ Otherwise, `v` shall be a pointer to or a glvalue of a polymorphic
44
  type ([[class.virtual]]).
45
 
46
  If `T` is “pointer to *cv* `void`,” then the result is a pointer to the
47
  most derived object pointed to by `v`. Otherwise, a run-time check is
48
  applied to see if the object pointed or referred to by `v` can be
 
62
  result points (refers) to the `C` subobject of the most derived
63
  object.
64
  - Otherwise, the run-time check *fails*.
65
 
66
  The value of a failed cast to pointer type is the null pointer value of
67
+ the required result type. A failed cast to reference type throws an
68
+ exception ([[except.throw]]) of a type that would match a handler (
69
+ [[except.handle]]) of type `std::bad_cast` ([[bad.cast]]).
70
 
71
  ``` cpp
72
  class A { virtual void f(); };
73
  class B { virtual void g(); };
74
  class D : public virtual A, private B { };