From Jason Turner

[expr.typeid]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp7xvc7r6r/{from.md → to.md} +12 -8
tmp/tmp7xvc7r6r/{from.md → to.md} RENAMED
@@ -22,38 +22,42 @@ value ([[conv.ptr]]), the `typeid` expression throws an exception (
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 type of the expression is a class type, the class
28
- shall be completely-defined. The expression is an unevaluated operand
29
- (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
  ``` cpp
44
- class D { /* ... */ };
45
  D d1;
46
  const D d2;
47
 
48
  typeid(d1) == typeid(d2); // yields true
49
  typeid(D) == typeid(const D); // yields true
50
  typeid(D) == typeid(d2); // yields true
51
  typeid(D) == typeid(const D&); // yields true
52
  ```
53
 
 
 
54
  If the header `<typeinfo>` ([[type.info]]) is not included prior to a
55
  use of `typeid`, the program is ill-formed.
56
 
57
- [[class.cdtor]] describes the behavior of `typeid` applied to an object
58
- under construction or destruction.
59
 
 
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*:
44
+
45
  ``` cpp
46
+ class D { ... };
47
  D d1;
48
  const D d2;
49
 
50
  typeid(d1) == typeid(d2); // yields true
51
  typeid(D) == typeid(const D); // yields true
52
  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