什么C ++ 0x头应该定义nullptr? [英] What C++0x Headers are supposed to define nullptr?

查看:139
本文介绍了什么C ++ 0x头应该定义nullptr?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在C ++ 0x几乎在这里,我一直在试验它,特别是使用nullptr。

Now that C++0x is almost here, I've been experimenting with it, and in particular using nullptr. I haven't been able to figure out what standard header files one is supposed to include if one needs to use it.

任何帮助都是值得赞赏的。

Any help is appreciated.

推荐答案

不需要标题。它是一个内置的关键字(§[lex.nullptr])。

No headers should be required. It is a built-in keyword (§[lex.nullptr]).


2.14.7指针字面量              [lex.nullptr]



2.14.7 Pointer literals                 [lex.nullptr]


指针文字:

        nullptr

指针字面值是关键字
nullptr 。它是
std :: nullptr_t 类型的prvalue。 [注意: std :: nullptr_t
是一个不同的类型,既不是
指针类型,
type;而是这种类型的prvalue这个
是一个空指针常量,可以是
转换为空指针值或
空成员指针值。见4.10
和4.11。 -endnote ]

The pointer literal is the keyword nullptr. It is a prvalue of type std::nullptr_t. [ Note: std::nullptr_t is a distinct type that is neither a pointer type nor a pointer to member type; rather, a prvalue of this type is a null pointer constant and can be converted to a null pointer value or null member pointer value. See 4.10 and 4.11. —endnote]






$ c> std :: nullptr_t ,但是在头< cstddef> (§[support.types] / 9 )。


Its type, std::nullptr_t, however, is "defined" in the header <cstddef> (§[support.types]/9).


nullptr_t 定义如下:

namespace std {
    typedef decltype(nullptr) nullptr_t;
}

nullptr_t 是同义词,具有3.9.1和4.10中描述的特性。 [注意:虽然不能使用 nullptr 的地址,但是另一个 nullptr_t 可以获取是左值的对象。 -endnote ]

The type for which nullptr_t is a synonym has the characteristics described in 3.9.1 and 4.10. [Note: Although nullptr’s address cannot be taken, the address of another nullptr_t object that is an lvalue can be taken. —endnote]

这篇关于什么C ++ 0x头应该定义nullptr?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆