gpt4 book ai didi

c++ - typeid nullptr name 的输出

转载 作者:搜寻专家 更新时间:2023-10-31 02:05:10 27 4
gpt4 key购买 nike

我知道整数和整数指针等的 typeid().name() 输出。但是被下面一行的输出弄糊涂了。

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

输出是Dn。它代表什么?

最佳答案

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.

这样做会导致

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

关于c++ - typeid nullptr name 的输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52361797/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com