What's the lifetime of memory pointed to typeinfo::name()?

c++, rtti, typeid, typeinfo

Solution

As long as the class with rtti exists. So if you deal with single executable - forever. But for classes in a Dynamic Link Librariy it shifts a little. Potentially you can unload it.

Problem

In C++ I can use `typeid` operator to retrieve the name of any polymorphic class: ``` const char* name = typeid( CMyClass ).name(); ``` How long will the string pointed to by the returned `const char*` pointer available to my program?

Original source