I’ve compiled the following code with g++, and got output, which written in comments.
template<class T>
void foo(T t) { cout << typeid(t).name() << endl; }
int main() {
foo("f"); //emits "PKc"
foo(string()); //emits "Ss"
}
I know, that type_info.name() isn’t standartized, but is there any way to get human-readable results?
Something like the following would be good enought
const char *
class string
You can use abi::__cxa_demangle for that (demangle function taken from here), just remember that the caller is responsible for freeing the return:
Example on ideone.