What is the actual purpose of std::type_info::name()?

后端 未结 2 1576
梦谈多话
梦谈多话 2020-12-05 05:05

Today a colleague of mine came and asked me the question as mentioned in the title.
He\'s currently trying to reduce the binaries footprint of a codebase, that is also u

2条回答
  •  广开言路
    2020-12-05 05:27

    Isolating this bit:

    • The point is, if they switch off RTTI, will exception handling still work properly in GCC? — πάντα ῥεῖ 1 hour ago

    The answer is yes:

    -fno-rtti

    Disable generation of information about every class with virtual functions for use by the C++ runtime type identification features (dynamic_cast and typeid). If you don't use those parts of the language, you can save some space by using this flag. Note that exception handling uses the same information, but it will generate it as needed. The dynamic_cast operator can still be used for casts that do not require runtime type information, i.e. casts to void * or to unambiguous base classes.

提交回复
热议问题