3

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?

  • Corrected. Was trying to make it look like italic format. – Avadhana Technologies Sep 17 '18 at 06:22
  • Use [c++filt -t](https://stackoverflow.com/a/19005800/1708801) -> `std::nullptr_t` – Shafik Yaghmour Sep 17 '18 at 06:24
  • If one of the answers below fixes your issue, you should accept it (click the check mark next to the appropriate answer). That does two things. It lets everyone know your issue has been resolved to your satisfaction, and it gives the person that helps you credit for the assist. [See here](http://meta.stackexchange.com/a/5235) for a full explanation. – hellow Sep 21 '18 at 09:23

2 Answers2

2

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)
hellow
  • 12,430
  • 7
  • 56
  • 79
1

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.

StoryTeller - Unslander Monica
  • 165,132
  • 21
  • 377
  • 458