From 4076592898465215198
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,fbd36da46c3cc7a0
X-Google-Attributes: gidf78e5,public
From: Gene Bushuyev <gbush@my-deja.com>
Subject: Re: Discussion: type_info
Date: 1999/12/13
Message-ID: <8316th$4j$1@nnrp1.deja.com>#1/1
X-Deja-AN: 560162176
X-NNTP-Posting-Host: 63.27.230.12
Approved: stephen.clamage@sun.com (comp.std.c++)
References: <384c8866.77375470@news.internetconnect.net> <memo.19991210152032.62499C@btinternet.com> <s55a88v5378@news.supernews.com>
X-UID: 0000000001
X-Status: $$$T
X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT)
X-Http-Proxy: 1.1 x31.deja.com:80 (Squid/1.1.22) for client 63.27.230.12
Organization: Deja.com - Before you buy.
X-Article-Creation-Date: Sun Dec 12 22:17:24 1999 GMT
X-MyDeja-Info: XMYDJUIDgbush
Newsgroups: comp.std.c++
Originator: clamage@taumet


In article <s55a88v5378@news.supernews.com>,
  "Andrei Alexandrescu" <andrewalex@hotmail.com> wrote:
>
> Dave Harris <scorp@btinternet.com> wrote in message
> news:memo.19991210152032.62499C@btinternet.com...
> [discussion about type_info::name]
>
> I think a reasonable set of requirements for type_info::name would be:
>
> * for a primitive type, type_info::name returns the name of that type.
> The position of const, presence of spaces etc. will be as follows:
> yadda, yadda, yadda.
> * for a class visible from the global namespace, type_info::name
> returns the name of the class, appropriately qualified. A prepending
> double colon will exist for all classes. For example, given:
>
> class A { ... };
> namespace N
> {
>     class B { class C; };
> }
>
> the names of the three classes will be: "::A", "::N::B", "::N::B::C".
>
[snip]
I think it's a good suggestion. Except, I would drop the leading "::"
because otherwise all the classes would have :: prepended to the name.
Also, for templates, it makes sense to return full qualified name of
instantiated class; and use the name as it appears in declaration of
template if it wasn't instantiated. E.g.
template<class T> class A{};
typeid(A<int>).name() returns "A<int>"
typeid(A).name() returns "template<class T> class A"
It isn't realy a problem if the names are very long. I guess all
compilers already have this functionality since when error occures you
can see the error messages with full names of templates, even when such
a name is 10K long. Actually, compiler doesn't have to store static
strings for instantiated templates names. It can include a piece of
code to produce such name on demand.
-------------------------------------
Gene Bushuyev


Sent via Deja.com http://www.deja.com/
Before you buy.


[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]




