Topic: [lib.type.info] What is the return value of type_info::name() ?


Author: Michael Cook <mcook@cognex.com>
Date: 1995/08/03
Raw View
>>>>> "JB" == Joe Borkoles <jborkole@jpmorgan.com> writes:

 JB> The following program outputs:

 JB> MyClass
 JB> 7

What, no scoping/namespace info?
I'd expect:

    ::MyClass
    9

Michael.





Author: Robert Buren <erarobu@era-t.ericsson.se>
Date: 1995/07/27
Raw View
Joe Borkoles <jborkole@jpmorgan.com> wrote:
>Robert Buren <erarobu@era-t.ericsson.se> wrote:
>
>>Has this been implemented on any compilers yet? If so, what _is_
>>the return value for those implementations?
>
>Under Borland C++, the return type is
>
>const char* type_info::name()

Yes, thank you. That complies with the standard.
What I meant was: "What is the contents of the
string returned from the expression

  type_id(my_object).name()

?"

/Robert
--
     Robert Buren
     erarobu@era-t.ericsson.se






Author: Joe Borkoles <jborkole@jpmorgan.com>
Date: 1995/07/28
Raw View
Robert Buren <erarobu@era-t.ericsson.se> wrote:
>Joe Borkoles <jborkole@jpmorgan.com> wrote:
>>Robert Buren <erarobu@era-t.ericsson.se> wrote:
>>
>>>Has this been implemented on any compilers yet? If so, what _is_
>>>the return value for those implementations?
>>
>>Under Borland C++, the return type is
>>
>>const char* type_info::name()
>
>Yes, thank you. That complies with the standard.
>What I meant was: "What is the contents of the
>string returned from the expression
>
>  type_id(my_object).name()
>
>?"
>
>/Robert
>--
>     Robert Buren
>     erarobu@era-t.ericsson.se
>

The following program outputs:

MyClass
7

-----------------------------------------------

#include <typeinfo.h>
#include <iostream.h>
#include <string.h>

class MyClass {};

int main()
{
   MyClass a;
   const char* s = typeid( a ).name();
   cout << s << endl << strlen( s ) << endl;
   return 0;
}


------------------------------------------------
I speak for myself and no one else.







Author: Robert Buren <erarobu@era-t.ericsson.se>
Date: 1995/07/26
Raw View
Why does type_info::name() return "an implementation defined value",
which "may be a null-terminated string ... suitable for conversion
and display as a wstring"?

Why isn't the return value specified in the standard? What can it
be used for (in portable programs), when it isn't specified? Why
not just return "namespace::class_name" or something like that?

Has this been implemented on any compilers yet? If so, what _is_
the return value for those implementations?

Thank you,

     Robert
--
     Robert Buren
     erarobu@era-t.ericsson.se






Author: Joe Borkoles <jborkole@jpmorgan.com>
Date: 1995/07/26
Raw View
Robert Buren <erarobu@era-t.ericsson.se> wrote:

>Has this been implemented on any compilers yet? If so, what _is_
>the return value for those implementations?
>

Under Borland C++, the return type is

const char* type_info::name()



-----------------------------------
I speak for myself and no one else.