c++ - 纯右值的结果

标签 c++ c++17

[basic.lval]/5状态:

The result of a prvalue is the value that the expression stores into its context. A prvalue whose result is the value V is sometimes said to have or name the value V. The result object of a prvalue is the object initialized by the prvalue; a non-discarded prvalue that is used to compute the value of an operand of a built-in operator or that has type cv void has no result object...

“存储到其上下文中” 是什么意思?那是我不明白的一部分。

最佳答案

好吧,其中一个是 [basic.lval]/1.2提到那些上下文

A prvalue is an expression whose evaluation initializes an object or a bit-field, or computes the value of the operand of an operator, as specified by the context in which it appears.

C++17 中变化的纯右值本身并不是值(保证复制省略),而是类似于延迟初始化对象(命名的或临时的)的“指令”。初始化被尽可能晚地延迟,这就是拷贝被“删除”的方式(但我离题了)。 “存储到其上下文中” 的意思是结果是这些指令为在各自的上下文中初始化这些对象而产生的结果。

关于c++ - 纯右值的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53909077/

相关文章:

关于增量运算符的 C++ 编译器问题

c++ - g++ 和 clang++ 自动参数模板特化的不同行为

c++ - 为什么当我在 const 之前写 noexcept 时出现错误

c++ - 检查套接字关闭

C++ 引用传递

c++ - 父类和子类之间的静态变量

c++ - 使用 C++17 是否可以检测结构/类是否有任何基础?

templates - 通过函数指针函数将lambda作为模板参数传递给模板

c++ - lambda 捕获的 const int 变量的值类别

c++:如何安全地将 const double** 转换为 const void**