51 lines
2.2 KiB
Markdown
51 lines
2.2 KiB
Markdown
[expr.comma]
|
||
|
||
# 7 Expressions [[expr]](./#expr)
|
||
|
||
## 7.6 Compound expressions [[expr.compound]](expr.compound#expr.comma)
|
||
|
||
### 7.6.20 Comma operator [expr.comma]
|
||
|
||
[1](#1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/expressions.tex#L8202)
|
||
|
||
The comma operator groups left-to-right[.](#1.sentence-1)
|
||
|
||
[expression:](#nt:expression "7.6.20 Comma operator [expr.comma]")
|
||
[*assignment-expression*](expr.assign#nt:assignment-expression "7.6.19 Assignment and compound assignment operators [expr.assign]")
|
||
[*expression*](#nt:expression "7.6.20 Comma operator [expr.comma]") , [*assignment-expression*](expr.assign#nt:assignment-expression "7.6.19 Assignment and compound assignment operators [expr.assign]")
|
||
|
||
A pair of expressions separated by a comma is evaluated left-to-right;
|
||
the left expression is
|
||
a [discarded-value expression](expr.prop#def:discarded-value_expression "7.2 Properties of expressions [expr.prop]")[.](#1.sentence-2)
|
||
|
||
The left expression is sequenced before
|
||
the right expression ([[intro.execution]](intro.execution "6.10.1 Sequential execution"))[.](#1.sentence-3)
|
||
|
||
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[.](#1.sentence-4)
|
||
|
||
[2](#2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/expressions.tex#L8222)
|
||
|
||
[*Note [1](#note-1)*:
|
||
|
||
In contexts where the comma token is given special meaning
|
||
(e.g., function calls ([[expr.call]](expr.call "7.6.1.3 Function call")),
|
||
subscript expressions ([[expr.sub]](expr.sub "7.6.1.2 Subscripting")),
|
||
lists of initializers ([[dcl.init]](dcl.init "9.5 Initializers")),
|
||
or [*template-argument-list*](temp.names#nt:template-argument-list "13.3 Names of template specializations [temp.names]")*s* ([[temp.names]](temp.names "13.3 Names of template specializations"))),
|
||
the comma operator as described in this subclause can appear only in parentheses[.](#2.sentence-1)
|
||
|
||
[*Example [1](#example-1)*:
|
||
|
||
f(a, (t=3, t+2), c); has three arguments, the second of which has the value5[.](#2.sentence-2)
|
||
|
||
â *end example*]
|
||
|
||
â *end note*]
|