The comma operator has been deprecated in subscripting expressions (as of C++20);[2] to reduce confusion, and open up the future possibility of repurposing the syntax for multidimensional array indexing.
In C++23, the ability to overload operator[] with multiple arguments was added making unparenthesised comma expressions unusable in subscripts.
In this example, the differing behavior between the second and third lines is due to the comma operator having lower precedence than assignment.
Further, because it is rarely used outside of specific idioms, and easily mistaken with other commas or the semicolon, it is potentially confusing and error-prone.
[6] The comma can be used in return statements, to assign to a global variable or out parameter (passed by reference).
For example, in setting a global error number: This can be written more verbosely as: For brevity, the comma can be used to avoid a block and associated braces, as in: instead of: In the OCaml and Ruby programming languages, the semicolon (";") is used for this purpose.