C++ 将Null指针常量转换为prvalue

C++ 将Null指针常量转换为prvalue,c++,null,C++,Null,空指针常量转换由以下规则描述。4.10/1 N3797: 整数类型的空指针常量可以转换为prvalue 类型std::nullptr\t。[注意:结果prvalue不是空值 指针值。-结束注释] 我认为以下是这种转换的一个例子: static_cast<std::nullptr_t>(0); static_cast(0); 但这似乎不是真的,因为 #include <iostream> #include <iostream> using namespace

空指针常量转换由以下规则描述。4.10/1 N3797:

整数类型的空指针常量可以转换为prvalue 类型std::nullptr\t。[注意:结果prvalue不是空值 指针值。-结束注释]

我认为以下是这种转换的一个例子:

static_cast<std::nullptr_t>(0);
static_cast(0);
但这似乎不是真的,因为

#include <iostream>
#include <iostream>
using namespace std;

int main()
{
    void *p = static_cast<std::nullptr_t>(0);
    cout << p; //0- Why? It is not a null pointer value
}
#包括
#包括
使用名称空间std;
int main()
{
void*p=静态_铸造(0);

cout表达式
p
是一个空指针。类型为
std::nullptr\t
的PR值可以转换为任何指针。它是初始化表达式
static\u cast(0)
而不是空指针值。

我感到困惑(真的)-当您将指针发送到std::cout?@doctorlove时,会发生什么情况?指针包含的地址会被打印出来。也就是说,prvalue的值不是空指针值,但可以转换为空指针值。您能否解释一下
static\u cast(0)的值是什么
?我认为它是
nullptr
@DmitryFucintv:它等于
nullptr
。它是一个类型为
std::nullptr\u t
的PR值,并且是唯一的此类值。