Bug 91847

Summary: init-capture pack of references requires ... on wrong side
Product: gcc Reporter: Barry Revzin <barry.revzin>
Component: c++Assignee: Not yet assigned to anyone <unassigned>
Severity: normal CC: webrown.cpp
Priority: P3 Keywords: rejects-valid
Version: 9.2.0   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2019-09-21 00:00:00

Description Barry Revzin 2019-09-20 23:26:03 UTC
gcc implements the letter of the standard and allows this:

template <typename... T>
void foo(T&... ts) {

While that is valid per the latest working draft, and is the wording specified in P0780R2, the direction we really want to go in is to put the ... on the other side of the &. That is, the declaration of 'us' should look the same as the declaration of 'ts'. This is CWG 2378.

In other words, the correct syntax should be:

template <typename... T>
void foo(T&... ts) {

clang implements the CWG 2378 rule, this issue should hopefully be resolved by the time C++20 ships.
Comment 1 Marek Polacek 2019-09-21 00:59:59 UTC
Comment 2 Barry Revzin 2020-02-15 17:28:43 UTC
In the Prague meeting, this paper (https://brevzin.github.io/cpp_proposals/2095_lambda_pack_cwg/p2095r0.html) was adopted into what will become the C++20 standard, which moves the & in the grammar to the left side of the ellipses. 

So now I can say officially, [&...us=ts]{} is the correct spelling.
Comment 3 Marek Polacek 2020-02-24 14:33:04 UTC
Actually this was just fixed: