我同意你关于副作用的说法 但逗号运算符应该不受副作用的影响?
以下这断话是The C++ Programming Language (The Third Edtion)的6.2.2里说的
The operators , (comma), && (logical and),and || (logical or)
guarantee that their left-hand operand is evaluated before their right-hand operand. For example,b=(a=2,a+1) assigns 3 to b.
On the other hand, it can be used within a parenthesized expression or within the second
expression of a conditional operator in such contexts. In the function call
f(a, (t=3, t+2), c)
the function has three arguments, the second of which has the value 5.
写的很清楚。
to:wingfiring(别逗了)
If an attempt is made to modify the result of a comma operator or to
access it after the next sequence point, the behavior is undefined.
有断章取义嫌疑。
2 The left operand of a comma operator is evaluated as a void expression; there is a
sequence point after its evaluation. Then the right operand is evaluated; the result has its
type and value.94) If an attempt is made to modify the result of a comma operator or to
access it after the next sequence point, the behavior is undefined.
3 EXAMPLE As indicated by the syntax, the comma operator (as described in this subclause) cannot
appear in contexts where a comma is used to separate items in a list (such as arguments to functions or lists
of initializers). On the other hand, it can be used within a parenthesized expression or within the second
expression of a conditional operator in such contexts. In the function call
f(a, (t=3, t+2), c)
the function has three arguments, the second of which has the value 5.