Files
cppdraft_translate/cppdraft/expr/comma.md
2025-10-25 03:02:53 +03:00

2.2 KiB

[expr.comma]

7 Expressions [expr]

7.6 Compound expressions [expr.compound]

7.6.20 Comma operator [expr.comma]

1

#

The comma operator groups left-to-right.

expression:
assignment-expression
expression , assignment-expression

A pair of expressions separated by a comma is evaluated left-to-right; the left expression is a discarded-value expression.

The left expression is sequenced before the right expression ([intro.execution]).

The type and value of the result are the type and value of the right operand; the result is of the same value category as its right operand, and is a bit-field if its right operand is a bit-field.

2

#

[Note 1:

In contexts where the comma token is given special meaning (e.g., function calls ([expr.call]), subscript expressions ([expr.sub]), lists of initializers ([dcl.init]), or template-argument-lists ([temp.names])), the comma operator as described in this subclause can appear only in parentheses.

[Example 1:

f(a, (t=3, t+2), c); has three arguments, the second of which has the value5.

— end example]

— end note]