[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: typeid(T).nameOfTheBeast()
From: |
Rolf Magnus |
Subject: |
Re: typeid(T).nameOfTheBeast() |
Date: |
Sat, 18 Jun 2005 12:13:52 +0200 |
Michael Olea wrote:
> Sometimes, in an introspective mood, my code reflecting on itself, I like
> to write test code that prints the results of introspection, some of which
> consist of the names of Types. The problem is: typeid(T).name(), in my
> usual worlds (e.g. gcc version 3.2.2 [FreeBSD] 20030205 (release)),
> returns an illegible mangling or a cryptic abbreviation. For example:
>
> typeid(unsigned int).name()
>
> returns "j". And while I do appreciate the savings involved it nonetheless
> irritates readers of the output - rather than "j" they would like to see
> "unsigned int". Bother!
Well, if you can live with using compiler specific functionality here, then
you could demangle that name. g++ uses just the same string that would be
used in name mangling. Look into the cxxabi.h header. It provides a
function abi::__cxa_demangle() that can convert the name returned by
typeid(T).name() into what you want.
xpost&f'up2 gnu.g++.help, because that group is clearly more appropriate for
answers to my posting.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: typeid(T).nameOfTheBeast(),
Rolf Magnus <=