On 2008-05-10 02:14:40 -0400, Greg Herlihy <greghe@[EMAIL PROTECTED]
> said:
> On May 9, 8:23 pm, Sean Hunt <ride...@[EMAIL PROTECTED]
> wrote:
>> On May 8, 9:27 pm, Venkat <swara...@[EMAIL PROTECTED]
> wrote:
>>
>>> While typeid(C).name() is guaranteed to be unique for each class C,
>>> it is NOT guaranteed to be anything human-understandable. This
>>> makes the function rather useless, but that's what the standard says.
>>
>> Unfortunately, not even. The result of type_info.name() is
>> unspecified, and no requirements are put onto it. "" is a perfectly
>> valid value of type_info.name() for any and all types.
>
> No - according to the C++ Standard, type_info name() returns an
> implementation-defined NTBS (null-terminated byte string) as the name
> of the requested type. [§18.5.1/7] Furthermore, according to
> §18.5.1/1, a type_info record effectively stores a pointer to a "name"
> for a type. Therefore, in order for typeid name() to "name" (that is,
> identify) a particular type, the string that type_info name() returns
> a) cannot be empty (because an empty string would not name anything)
> and b) must be a name different from the name that type_info name()
> returns for any other type (since such a name would not unambiguously
> identify its type).
>
Paragraph 1 isn't normative. It's descriptive material that tells
readers generally how the class works. The requirement for the name()
member function is in paragraph 7, and it is simply: "Returns: An
implementation-defined NTBS."
--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
(www.petebecker.com/tr1book)
[ See http://www.gotw.ca/resources/clcm.htm
for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]


|