The result of a typeid expression is an lvalue of static type
conststdโ::โtype_ยญinfo ([type.info]) and dynamic type conststdโ::โtype_ยญinfo or constname where name is an
implementation-defined class publicly derived from
stdโ::โtype_ยญinfo which preserves the behavior described
in [type.info].62
The lifetime of the object referred to by the lvalue extends to the end
of the program.
Whether or not the destructor is called for the
stdโ::โtype_ยญinfo object at the end of the program is unspecified.
When typeid is applied to a glvalue whose type is a
polymorphic class type ([class.virtual]), the result refers to a
stdโ::โtype_ยญinfo object representing the type of the most derived
object ([intro.object]) (that is, the dynamic type) to which the
glvalue refers.
If the glvalue is obtained by applying the
unary * operator to a pointer63
and the pointer is a null pointer value ([basic.compound]), the
typeid expression throws an exception ([except.throw]) of
a type that would match a handler of type
stdโ::โbad_ยญtypeid
exception ([bad.typeid]).
When typeid is applied to an expression other than a glvalue of
a polymorphic class type, the result refers to a stdโ::โtype_ยญinfo
object representing the static type of the expression.
When typeid is applied to a type-id, the result
refers to a stdโ::โtype_ยญinfo object representing the type of the
type-id.
If the type of the type-id is a reference
to a possibly cv-qualified type, the result of the
typeid expression refers to a stdโ::โtype_ยญinfo object
representing the cv-unqualified referenced type.
If the type of
the type-id is a class type or a reference to a class type,
the class shall be completely-defined.
If the type of the expression or type-id is a
cv-qualified type, the result of the typeid expression refers
to a stdโ::โtype_ยญinfo object representing the cv-unqualified
type.