@AbstractionAnon - I'm not quite sure what you're disagreeing with for the first snippet. Of course that prints "FALSE". Just as the following does:
using namespace std;
int a = 0;
int temp = a++;
Edit: I sort of understand where the disagreement is. And after thinking about it, I agree with your wording. But I'm trying not to get bogged down by standardese, that I don't even fully understand myself.
From what I understand, it boils down to five points:
- "Evaluation" includes both the value computation and the side effect.
- If A is sequenced before B, then evaluation of A will be complete before evaluation of B begins.
- The value computation of the built-in post-increment and post-decrement operators is sequenced before its side-effect.
- The side effect of the built-in pre-increment and pre-decrement operators is sequenced before its value computation (implicit rule due to definition as compound assignment).
- The side effect (modification of the left argument) of the built-in assignment operator and of all built-in compound assignment operators is sequenced after the value computation (but not the side effects) of both left and right arguments, and is sequenced before the value computation of the assignment expression (that is, before returning the reference to the modified object).
But the above is really wordy and confusing
. So my point is that regardless of preincrement, postincrement, or assignment, you can think of all of them as just being a function, where a function has side effects that happen within it, and then a return value.
I fixed the second snippet (forgot the reference), thank you. I updated my original post to try to clarify what I wrote. Sorry for the confusion. I believe my code snippets are valid, and are a nice generalized way of looking at things.