tmp/tmp52suttik/{from.md → to.md}
RENAMED
|
@@ -1,30 +1,34 @@
|
|
| 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`
|
| 6 |
publicly derived from `std::type_info` which preserves the behavior
|
| 7 |
-
described in [[type.info]].[^
|
| 8 |
|
| 9 |
The lifetime of the object referred to by the lvalue extends to the end
|
| 10 |
of the program. Whether or not the destructor is called for the
|
| 11 |
`std::type_info` object at the end of the program is unspecified.
|
| 12 |
|
| 13 |
If the type of the *expression* or *type-id* operand is a (possibly
|
| 14 |
cv-qualified) class type or a reference to (possibly cv-qualified) class
|
| 15 |
type, that class shall be completely defined.
|
| 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
When `typeid` is applied to a glvalue whose type is a polymorphic class
|
| 18 |
type [[class.virtual]], the result refers to a `std::type_info` object
|
| 19 |
representing the type of the most derived object [[intro.object]] (that
|
| 20 |
-
is, the dynamic type) to which the glvalue refers.
|
| 21 |
-
obtained by applying the unary `*` operator to a pointer[^16]
|
| 22 |
-
|
| 23 |
-
and the pointer is a null pointer value [[basic.compound]], the `typeid`
|
| 24 |
-
expression throws an exception [[except.throw]] of a type that would
|
| 25 |
-
match a handler of type `std::bad_typeid` exception [[bad.typeid]].
|
| 26 |
|
| 27 |
When `typeid` is applied to an expression other than a glvalue of a
|
| 28 |
polymorphic class type, the result refers to a `std::type_info` object
|
| 29 |
representing the static type of the expression. Lvalue-to-rvalue
|
| 30 |
[[conv.lval]], array-to-pointer [[conv.array]], and function-to-pointer
|
|
@@ -37,11 +41,11 @@ When `typeid` is applied to a *type-id*, the result refers to a
|
|
| 37 |
`std::type_info` object representing the type of the *type-id*. If the
|
| 38 |
type of the *type-id* is a reference to a possibly cv-qualified type,
|
| 39 |
the result of the `typeid` expression refers to a `std::type_info`
|
| 40 |
object representing the cv-unqualified referenced type.
|
| 41 |
|
| 42 |
-
[*Note
|
| 43 |
*cv-qualifier-seq* or a *ref-qualifier* [[dcl.fct]]. — *end note*]
|
| 44 |
|
| 45 |
If the type of the expression or *type-id* is a cv-qualified type, the
|
| 46 |
result of the `typeid` expression refers to a `std::type_info` object
|
| 47 |
representing the cv-unqualified type.
|
|
@@ -64,8 +68,8 @@ typeid(D) == typeid(const D&); // yields true
|
|
| 64 |
The type `std::type_info` [[type.info]] is not predefined; if a standard
|
| 65 |
library declaration [[typeinfo.syn]], [[std.modules]] of
|
| 66 |
`std::type_info` does not precede [[basic.lookup.general]] a `typeid`
|
| 67 |
expression, the program is ill-formed.
|
| 68 |
|
| 69 |
-
[*Note
|
| 70 |
applied to an object under construction or destruction. — *end note*]
|
| 71 |
|
|
|
|
| 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]].[^14]
|
| 8 |
|
| 9 |
The lifetime of the object referred to by the lvalue extends to the end
|
| 10 |
of the program. Whether or not the destructor is called for the
|
| 11 |
`std::type_info` object at the end of the program is unspecified.
|
| 12 |
|
| 13 |
If the type of the *expression* or *type-id* operand is a (possibly
|
| 14 |
cv-qualified) class type or a reference to (possibly cv-qualified) class
|
| 15 |
type, that class shall be completely defined.
|
| 16 |
|
| 17 |
+
If an *expression* operand of `typeid` is a possibly-parenthesized
|
| 18 |
+
*unary-expression* whose *unary-operator* is `*` and whose operand
|
| 19 |
+
evaluates to a null pointer value [[basic.compound]], the `typeid`
|
| 20 |
+
expression throws an exception [[except.throw]] of a type that would
|
| 21 |
+
match a handler of type `std::bad_typeid` [[bad.typeid]].
|
| 22 |
+
|
| 23 |
+
[*Note 1*: In other contexts, evaluating such a *unary-expression*
|
| 24 |
+
results in undefined behavior [[expr.unary.op]]. — *end note*]
|
| 25 |
+
|
| 26 |
When `typeid` is applied to a glvalue whose type is a polymorphic class
|
| 27 |
type [[class.virtual]], the result refers to a `std::type_info` object
|
| 28 |
representing the type of the most derived object [[intro.object]] (that
|
| 29 |
+
is, the dynamic type) to which the glvalue refers.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
When `typeid` is applied to an expression other than a glvalue of a
|
| 32 |
polymorphic class type, the result refers to a `std::type_info` object
|
| 33 |
representing the static type of the expression. Lvalue-to-rvalue
|
| 34 |
[[conv.lval]], array-to-pointer [[conv.array]], and function-to-pointer
|
|
|
|
| 41 |
`std::type_info` object representing the type of the *type-id*. If the
|
| 42 |
type of the *type-id* is a reference to a possibly cv-qualified type,
|
| 43 |
the result of the `typeid` expression refers to a `std::type_info`
|
| 44 |
object representing the cv-unqualified referenced type.
|
| 45 |
|
| 46 |
+
[*Note 2*: The *type-id* cannot denote a function type with a
|
| 47 |
*cv-qualifier-seq* or a *ref-qualifier* [[dcl.fct]]. — *end note*]
|
| 48 |
|
| 49 |
If the type of the expression or *type-id* is a cv-qualified type, the
|
| 50 |
result of the `typeid` expression refers to a `std::type_info` object
|
| 51 |
representing the cv-unqualified type.
|
|
|
|
| 68 |
The type `std::type_info` [[type.info]] is not predefined; if a standard
|
| 69 |
library declaration [[typeinfo.syn]], [[std.modules]] of
|
| 70 |
`std::type_info` does not precede [[basic.lookup.general]] a `typeid`
|
| 71 |
expression, the program is ill-formed.
|
| 72 |
|
| 73 |
+
[*Note 3*: Subclause [[class.cdtor]] describes the behavior of `typeid`
|
| 74 |
applied to an object under construction or destruction. — *end note*]
|
| 75 |
|