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

51 lines
2.2 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[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.20Comma operator[expr.comma]")
[*assignment-expression*](expr.assign#nt:assignment-expression "7.6.19Assignment and compound assignment operators[expr.assign]")
[*expression*](#nt:expression "7.6.20Comma operator[expr.comma]") , [*assignment-expression*](expr.assign#nt:assignment-expression "7.6.19Assignment 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.2Properties of expressions[expr.prop]")[.](#1.sentence-2)
The left expression is sequenced before
the right expression ([[intro.execution]](intro.execution "6.10.1Sequential 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.3Function call")),
subscript expressions ([[expr.sub]](expr.sub "7.6.1.2Subscripting")),
lists of initializers ([[dcl.init]](dcl.init "9.5Initializers")),
or [*template-argument-list*](temp.names#nt:template-argument-list "13.3Names of template specializations[temp.names]")*s* ([[temp.names]](temp.names "13.3Names 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*]