From Jason Turner

[expr.typeid]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpzejutvzs/{from.md → to.md} +29 -27
tmp/tmpzejutvzs/{from.md → to.md} RENAMED
@@ -1,43 +1,45 @@
1
- ### Type identification <a id="expr.typeid">[[expr.typeid]]</a>
2
 
3
  The result of a `typeid` expression is an lvalue of static type `const`
4
- `std::type_info` ([[type.info]]) and dynamic type `const`
5
- `std::type_info` or `const` *name* where *name* is an
6
- *implementation-defined* class publicly derived from `std::type_info`
7
- which preserves the behavior described in  [[type.info]].[^9] The
8
- lifetime of the object referred to by the lvalue extends to the end of
9
- the program. Whether or not the destructor is called for the
10
- `std::type_info` object at the end of the program is unspecified.
11
 
12
- When `typeid` is applied to a glvalue expression whose type is a
13
- polymorphic class type ([[class.virtual]]), the result refers to a
14
- `std::type_info` object representing the type of the most derived
15
- object ([[intro.object]]) (that is, the dynamic type) to which the
16
- glvalue refers. If the glvalue expression is obtained by applying the
17
- unary `*` operator to a pointer[^10] and the pointer is a null pointer
18
- value ([[conv.ptr]]), the `typeid` expression throws an exception (
19
- [[except.throw]]) of a type that would match a handler of type
20
- `std::bad_typeid` exception ([[bad.typeid]]).
21
 
22
  When `typeid` is applied to an expression other than a glvalue of a
23
  polymorphic class type, the result refers to a `std::type_info` object
24
- representing the static type of the expression. Lvalue-to-rvalue (
25
- [[conv.lval]]), array-to-pointer ([[conv.array]]), and
26
- function-to-pointer ([[conv.func]]) conversions are not applied to the
27
- expression. If the expression is a prvalue, the temporary
28
- materialization conversion ([[conv.rval]]) is applied. The expression
29
- is an unevaluated operand (Clause  [[expr]]).
30
 
31
  When `typeid` is applied to a *type-id*, the result refers to a
32
  `std::type_info` object representing the type of the *type-id*. If the
33
  type of the *type-id* is a reference to a possibly cv-qualified type,
34
  the result of the `typeid` expression refers to a `std::type_info`
35
  object representing the cv-unqualified referenced type. If the type of
36
  the *type-id* is a class type or a reference to a class type, the class
37
  shall be completely-defined.
38
 
 
 
 
39
  If the type of the expression or *type-id* is a cv-qualified type, the
40
  result of the `typeid` expression refers to a `std::type_info` object
41
  representing the cv-unqualified type.
42
 
43
  [*Example 1*:
@@ -53,11 +55,11 @@ typeid(D) == typeid(d2); // yields true
53
  typeid(D) == typeid(const D&); // yields true
54
  ```
55
 
56
  — *end example*]
57
 
58
- If the header `<typeinfo>` ([[type.info]]) is not included prior to a
59
- use of `typeid`, the program is ill-formed.
60
 
61
- [*Note 1*: [[class.cdtor]] describes the behavior of `typeid` applied
62
- to an object under construction or destruction. — *end note*]
63
 
 
1
+ #### Type identification <a id="expr.typeid">[[expr.typeid]]</a>
2
 
3
  The result of a `typeid` expression is an lvalue of static type `const`
4
+ `std::type_info` [[type.info]] and dynamic type `const` `std::type_info`
5
+ or `const` *name* where *name* is an *implementation-defined* class
6
+ publicly derived from `std::type_info` which preserves the behavior
7
+ described in  [[type.info]].[^15] The lifetime of the object referred to
8
+ by the lvalue extends to the end of the program. Whether or not the
9
+ destructor is called for the `std::type_info` object at the end of the
10
+ program is unspecified.
11
 
12
+ When `typeid` is applied to a glvalue whose type is a polymorphic class
13
+ type [[class.virtual]], the result refers to a `std::type_info` object
14
+ representing the type of the most derived object [[intro.object]] (that
15
+ is, the dynamic type) to which the glvalue refers. If the glvalue is
16
+ obtained by applying the unary `*` operator to a pointer[^16] and the
17
+ pointer is a null pointer value [[basic.compound]], the `typeid`
18
+ expression throws an exception [[except.throw]] of a type that would
19
+ match a handler of type `std::bad_typeid` exception [[bad.typeid]].
 
20
 
21
  When `typeid` is applied to an expression other than a glvalue of a
22
  polymorphic class type, the result refers to a `std::type_info` object
23
+ representing the static type of the expression. Lvalue-to-rvalue
24
+ [[conv.lval]], array-to-pointer [[conv.array]], and function-to-pointer
25
+ [[conv.func]] conversions are not applied to the expression. If the
26
+ expression is a prvalue, the temporary materialization conversion
27
+ [[conv.rval]] is applied. The expression is an unevaluated operand
28
+ [[expr.prop]].
29
 
30
  When `typeid` is applied to a *type-id*, the result refers to a
31
  `std::type_info` object representing the type of the *type-id*. If the
32
  type of the *type-id* is a reference to a possibly cv-qualified type,
33
  the result of the `typeid` expression refers to a `std::type_info`
34
  object representing the cv-unqualified referenced type. If the type of
35
  the *type-id* is a class type or a reference to a class type, the class
36
  shall be completely-defined.
37
 
38
+ [*Note 1*: The *type-id* cannot denote a function type with a
39
+ *cv-qualifier-seq* or a *ref-qualifier* [[dcl.fct]]. — *end note*]
40
+
41
  If the type of the expression or *type-id* is a cv-qualified type, the
42
  result of the `typeid` expression refers to a `std::type_info` object
43
  representing the cv-unqualified type.
44
 
45
  [*Example 1*:
 
55
  typeid(D) == typeid(const D&); // yields true
56
  ```
57
 
58
  — *end example*]
59
 
60
+ If the header `<typeinfo>` is not imported or included prior to a use of
61
+ `typeid`, the program is ill-formed.
62
 
63
+ [*Note 2*: Subclause [[class.cdtor]] describes the behavior of `typeid`
64
+ applied to an object under construction or destruction. — *end note*]
65