When [P0780R2] was adopted in Jacksonville in 2018, the paper contained a grammar rule that was inconsistent with other uses of packs. As pointed out by Richard Smith a few hours after plenary [Smith.Core], the grammar requires a pack of references to be captured like:
rather than how we write packs of references everywhere else.
This is now [CWG2378].
As of this writing, clang implements the Core Issue direction (with the
& preceeding the
...) and gcc implements the standard wording. I opened a gcc bug for this [gcc.91847], but we should really fix the wording asap.
This paper exists to do that.
Change the grammar in 188.8.131.52 [expr.prim.lambda.capture]:
capture: - simple-capture
...opt init-capture + simple-capture + init-capture simple-capture: - identifier - & identifier + identifier
...opt + & identifier
...opt this * this init-capture: - identifier initializer - & identifier initializer +
...opt identifier initializer + &
...opt identifier initializer
Change 184.108.40.206 [expr.prim.lambda.capture]/2:
If a lambda-capture includes a capture-default that is
=, each simple-capture of that lambda-capture shall be of the form “
...opt identifier”, “
this”, or “
Change 220.127.116.11 [expr.prim.lambda.capture]/6:
An init-capture without ellipsis behaves as if it declares and explicitly captures a variable of the form “
auto init-capture ;” whose declarative region is the lambda-expression’s compound-statement, except that:
Change 18.104.22.168 [expr.prim.lambda.capture]/17:
17 A simple-capture
followed bycontaining an ellipsis is a pack expansion ([temp.variadic]). An init-capture preceded bycontaining an ellipsis is a pack expansion that introduces an init-capture pack ([temp.variadic]) whose declarative region is the lambda-expression’s compound-statement.
Change 13.7.3 [temp.variadic]/5.10:
5 […] Pack expansions can occur in the following contexts:
- (5.10) In a capture-list ([expr.prim.lambda]); the pattern is
a capturethe capture without the ellipses.
[CWG2378] Barry Revzin. 2018. Inconsistent grammar for reference init-capture of pack.
[gcc.91847] Barry Revzin. 2019. init-capture pack of references requires … on wrong side.
[P0780R2] Barry Revzin. 2018. Allow pack expansion in lambda init-capture.
[Smith.Core] Richard Smith. 2018. p0780r2 has wrong grammar for reference init-capture packs.