If I call typeid
and retrieve the address of returned type_info
:
const type_info* info = &( typeid( Something ) );
what's the lifetime of the object returned by typeid
and how long will the pointer to that object remain valid?
However the implementation implements them, the results of typeid
expressions are lvalues and the lifetime of the objects that those lvalues refer to must last until the end of the program.
From ISO/IEC 14882:2003 5.2.8 [expr.typeid]:
The result of a
typeid
expression is an lvalue [...] The lifetime of the object referred to by the lvalue extends to the end of the program.