Reputation: 355
I have found next built-in operators which can return in Clause 5:
new, delete, function call, logical OR, all assignments operators.
It's all clear about the first three operators:
Other built-in operators didn't call functions. So how they can return something?
We can say only that such operators evaluate the result value or produce side effects like any other expressions.
Are there two inaccuracies in the Standard about built-in logical AND and built-in assignment operators?
Let's look at logical OR (§5.15/1):
The || operator groups left-to-right. The operands are both contextually converted to bool (Clause 4). It returns true if either of its operands is true, and false otherwise.
Compare with the technically correct definition of logical AND (§5.14/1):
The && operator groups left-to-right. The operands are both contextually converted to bool (Clause 4). The result is true if both operands are true and false otherwise.
Why they used "returns" in case of || operator and "the result is" in case of logical AND?
Next look at the built-in assignment operators (§5.18/1).
All require a modifiable lvalue as their left operand and return an lvalue referring to the left operand.
Again we see "return" instead of "the result is".
P.S. I didn't find any phrases like "expression returns" in the Standard so it seems that such phrases are technically incorrect. Using them may cause strange questions
Upvotes: 0
Views: 89
Reputation: 355
From the discussion above (thanks to Matteo Italia) we can conclude that there is absolutely NO difference between concepts "return the result" and "yield/evaluate the result value" for built-in operators (at least for built-in types which are the only ones that are interesting for the rules of built in operators).
Upvotes: 1