GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::type_info::name(3) C++ Standard Libary std::type_info::name(3)

std::type_info::name - std::type_info::name


const char* name() const; (until C++11)
const char* name() const noexcept; (since C++11)


Returns an implementation defined null-terminated character string containing the
name of the type. No guarantees are given; in particular, the returned string can be
identical for several types and change between invocations of the same program.


(none)


null-terminated character string containing the name of the type.


The lifetime of the array pointed to by the returned pointer is not specified, but
in practice it persist as long as the RTTI data structure for the given type exists,
which has application lifetime unless loaded from a dynamic library (that can be
unloaded).


Some implementations (such as MSVC, IBM, Oracle) produce a human-readable type name.
Others, most notably gcc and clang, return the mangled name, which is specified by
the Itanium C++ ABI. The mangled name can be converted to human-readable form using
implementation-specific API such as abi::__cxa_demangle directly or through
boost::core::demangle. It can also be piped through the commandline utility c++filt
-t.

// Run this code


#include <boost/core/demangle.hpp>


#include <iostream>
#include <typeinfo>


struct Base { virtual ~Base() = default; };
struct Derived : Base {};


int main() {
Base b1;
Derived d1;


const Base *pb = &b1;
std::cout << typeid(*pb).name() << '\n';
pb = &d1;
std::cout << typeid(*pb).name() << '\n';


std::string real_name = boost::core::demangle(typeid(pb).name());
std::cout << typeid(pb).name() << " => " << real_name << '\n';
}


// GCC/Clang:
4Base
7Derived
PK4Base => Base const*
// MSVC:
struct Base
struct Derived
struct Base const * __ptr64 => struct Base const * __ptr64


hash_code returns a value which is identical for the same types
(C++11) (public member function)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.