为整数文字赋值
Assigning value to integer literal
Whenever a prvalue appears as an operand of an operator that expects a glvalue for that operand, the temporary materialization conversion is applied to convert the expression to an xvalue.
为什么 5 = 6
格式错误?它不应该执行临时物化转换,并创建一个可分配的临时文件吗?
5 = 6
是非法的。也就是说,它是非法的,因为 [expr.ass]/1 explicitly says so:
All [assignment operators] require a modifiable lvalue as their left operand
5 不是可修改的左值。因此,违反了这条规则并且代码是非良构的。请注意,它通常不期望“glvalue”;它需要一个“可修改的左值”特别是。
Whenever a prvalue appears as an operand of an operator that expects a glvalue for that operand, the temporary materialization conversion is applied to convert the expression to an xvalue.
为什么 5 = 6
格式错误?它不应该执行临时物化转换,并创建一个可分配的临时文件吗?
5 = 6
是非法的。也就是说,它是非法的,因为 [expr.ass]/1 explicitly says so:
All [assignment operators] require a modifiable lvalue as their left operand
5 不是可修改的左值。因此,违反了这条规则并且代码是非良构的。请注意,它通常不期望“glvalue”;它需要一个“可修改的左值”特别是。