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.
Why is 5 = 6
ill-formed? Should it not perform a temporary materialization conversion, and create an assignable temporary?
CodePudding user response:
5 = 6
is illegal by fiat. That is, it's illegal because [expr.ass]/1 explicitly says so:
All [assignment operators] require a modifiable lvalue as their left operand
5 is not a modifiable lvalue. Therefore, this rule is violated and the code is il-formed. Note that it doesn't expect a "glvalue" generally; it requires a "modifiable lvalue" specifically.