What is the memory lifetime point to typeinfo :: name ()?

In C ++, I can use the typeid operator to get the name of any polymorphic class:

 const char* name = typeid( CMyClass ).name(); 

How long will the string be pointed to by the returned const char* pointer available to my program?

+5
source share
2 answers

While the class with rtti exists. Therefore, if you are dealing with one executable file - forever. But for classes in Dynamic Link Librariy, it changes a bit. You can potentially unload it.

+15
source

The memory returned by type_info::name() will be available for the lifetime of the application.

+3
source

Source: https://habr.com/ru/post/886621/


All Articles