type_info::name

Martin v. Loewis martin@loewis.home.cs.tu-berlin.de
Fri Mar 3 10:20:00 GMT 2000


> Is there a possibility to get a readable class name from type_info::name?
> With g++ I
> get
> t12basic_string3ZcZt18string_char_traits1ZcZt24__default_alloc_template2b1i0.

Not really. If you slightly tweak this string, you can pass it too
c++filt:

mira% c++filt foo__t12basic_string3ZcZt18string_char_traits1ZcZt24__default_alloc_template2b1i0 
basic_string<char, string_char_traits<char>, __default_alloc_template<true, 0> >::foo(void)

If you then strip the '::foo(void)' part, you get the type
name. Instead of c++filt, you can also use cplus_demangle, which is a
function from -liberty.

Regards,
Martin

P.S. I'd question whether the second form is more readable than the
first one, though.


More information about the Gcc mailing list