RTTI in C++ [] (RTTI in C++), Lektion, page 722685
https://www.purl.org/stefan_ram/pub/rtti_c++ (permalink) is the canonical URI of this page.
Stefan Ram
C++-Kurs

RTTI in C++ 

main.cpp

#include <iostream>
#include <ostream>
#include <typeinfo>

int main()
{ ::std::cout << typeid( 1 ).name() << '\n';
::std::cout << typeid( 1.1 ).name() << '\n';
::std::cout << typeid( 1.1f ).name() << '\n';
::std::cout << typeid( 1u ).name() << '\n'; }

transcript
i
d
f
j

Der zurückgegebene Name  ist implementationsspezifisch. (Eine Implementation ist nicht einmal verpflichtet, überhaupt unterschiedliche Namen für unterschiedliche Typen zu ergeben.)

GNU C++ compiler 

Die Funktion »::abi::__cxa_demangle« findet sich nur unter wenigen Implementation, wie beispielsweise dem GNU C++ compiler .

main.cpp

#include <cxxabi.h>
#include <iostream>
#include <ostream>
#include <typeinfo>

static const char * decode( const char * const typnam )
{ static char buf[ 9999 ]; size_t size = sizeof( buf ); int st;
char const * const result = ::abi::__cxa_demangle( typnam, buf, &size, &st );
buf[ size - 1 ]= 0; return result; }

int main()
{ ::std::cout << decode( typeid( 1 ).name() )<< '\n';
::std::cout << decode( typeid( 1.1 ).name() )<< '\n';
::std::cout << decode( typeid( 1.1f ).name() )<< '\n';
::std::cout << decode( typeid( 1u ).name() )<< '\n'; }

transcript
int
double
float
unsigned int

About this page, Impressum  |   Form for messages to the publisher regarding this page  |   "ram@zedat.fu-berlin.de" (without the quotation marks) is the email-address of Stefan Ram.   |   A link to the start page of Stefan Ram appears at the top of this page behind the text "Stefan Ram".)  |   Copyright 1998-2014 Stefan Ram, Berlin. All rights reserved. This page is a publication by Stefan Ram. relevant keywords describing this page: Stefan Ram Berlin slrprd slrprd stefanramberlin spellched stefanram722685 stefan_ram:722685 RTTI in C++ Stefan Ram, Berlin, and, or, near, uni, online, slrprd, slrprdqxx, slrprddoc, slrprd722685, slrprddef722685, PbclevtugFgrsnaEnz Erklärung, Beschreibung, Info, Information, Hinweis,

Copyright 1998-2014 Stefan Ram, Berlin. All rights reserved. This page is a publication by Stefan Ram.
https://www.purl.org/stefan_ram/pub/rtti_c++