Output of typeid nullptr name

Viewed 688

I am aware of typeid().name() output of integers and integer pointer etc. But got confused by the output of below line.

cout << typeid(nullptr).name() << endl; //Dn

The output was Dn. What does it stands for?

2 Answers

std::type_info::name returns a mangled name

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.
[..]
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.

Doing so will lead to

$ echo 'Dn' | c++filt -t
decltype(nullptr)

There is no answer in the scope of the C++ itself. The string returned by the std::type_info::name member is implementation defined. It depends on your implementation (compiler) of C++, your target platform and the ABI it's adhering to.

Related