gpt4 book ai didi

c++ - 左值到右值的转换

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:19:56 26 4
gpt4 key购买 nike

从 4.1/2

The value contained in the object indicated by the lvalue is the rvalue result. When an lvalue-to-rvalue conversion occurs within the operand of sizeof (5.3.3) the value contained in the referenced object is not accessed, since that operator does not evaluate its operand.

出于好奇,我在想,这是否同样适用于 if、for、while 语句,即在计算语句结果时将左值转换为右值?

最佳答案

是的。没有 lvalue-to-rvalue 转换,它无法读取它的

笼统地说,将左值视为某种容器,将右值视为容器中包含的值。

C++03,§3.10/7 节读取,

Whenever an lvalue appears in a context where an rvalue is expected, the lvalue is converted to an rvalue; see 4.1, 4.2, and 4.3.

与 §4.1/2(您的引文)一起阅读,

The value contained in the object indicated by the lvalue is the rvalue result.

相关主题:

关于c++ - 左值到右值的转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7460410/

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