type_info::name question
Thomas Kunert
kunert@physik.tu-dresden.de
Mon Sep 21 09:44:00 GMT 1998
Alexandre Oliva wrote:
>
> Thomas Kunert <kunert@physik.tu-dresden.de> writes:
>
> > Alexandre Oliva wrote:
>
> >> type_info::name *isn't* useful at all, as defined in the standard.
>
> > ``Implementation defined'' doesn't mean ``as unuseful as possible to
> > prevent portability problems'' but ``make the best of it, everybody
> > should know about portability''. And if the function does what it's name
> > suggests -- giving the name of the type in some readable language -- it
> > *is* useful.
>
> Then please tell us what the following program should print [note: it
> does not compile with egcs 1.1, only with newer snapshots]:
>
> #include <iostream>
> #include <string>
> #include <typeinfo>
>
> template <typename T>
> struct foo {
> foo() {
> struct test {
> test() { std::cout << typeid(*this).name() << std::endl; }
> } mytest;
> }
> };
>
> main() {
> foo<std::string> bar;
> }
>
> If you can find a readable and portable representation of that, then
> you're free to try to implement it within egcs.
What means `portable' in that case? I don't expect the same result on
all platform, I just expect any readable representation of the typename.
How about the string used for error messages? IRIX C++ gives `test', IMO
even this is OK.
Perhaps I should give an example for my intended purpose.
I've a library for parsing command line options. Some of these options
take parameters. There is an automatic help facility: The library can,
without any application code, print the type of the expected parameters.
Implementing it is my weak point: Even if I was able to do the hacking,
I can't provide the necessary paperwork. Therefore I take the easier
way: I just demand the desired features :-)
Please don't take it wrong: I'm _very_ satisfied with EGCS, and use it
for all my programming. I just want to make a proposal on how to make it
even better.
>
> On how many other compilers does your perfectly working code would run
> before you ported it to egcs?
One. SGI-C++. But I switched to a better compiler :).
Regards,
Thomas
More information about the Gcc
mailing list