第4.10/1节N3797说:
null指针常量是一个整数文本(2.14.2),其值为零或std::nullptr_t类型的prvalue。
我认为nullptr是std::nullptr_t类型的prvalue。你能得到更多这样的prvalue的例子吗?
发布于 2014-07-31 13:44:27
与任何类型一样,有多种方法可以获得std::nullptr_t类型的prvalue
static_cast<std::nullptr_t>(0)std::nullptr_t{}std::nullptr_t:std::nullptr_t f() { return {}; } f()的函数std::nullptr_t:[]() -> std::nullptr_t { return {}; }()的lambdastd::nullptr_t prvalue:("hello", nullptr)std::nullptr_t类型,而另一侧属于不同的值类别,或者是抛出表达式:false ? throw "oops" : nullptr、false ? std::move(nullptr) : nullptr。因为std::nullptr_t不参与大多数操作符,所以这是一个相当累人的列表;大多数具有std::nullptr_t类型的其他表达式都会产生glvalue。
https://stackoverflow.com/questions/25060360
复制相似问题