1 // RUN: %clang_cc1 -std=c++2a -verify %s
5 template <typename
... Args
> void foo(Args
... args
) {
6 (void)[... xs
= args
] {
17 template<typename
...T
> void f(T
...t
) {
19 x
; // expected-error {{unexpanded parameter pack 'x'}}
22 // Not OK: can't expand 'x' outside its scope.
23 weird((void)[&...x
= t
] {
24 return &x
; // expected-error {{unexpanded parameter pack 'x'}}
25 }... // expected-error {{does not contain any unexpanded}}
28 // OK, capture only one 'slice' of 'x'.
29 weird((void)[&x
= t
] {
34 // 'x' is not expanded by the outer '...', but 'T' is.
35 weird((void)[&... x
= t
] {
36 return T() + &x
; // expected-error {{unexpanded parameter pack 'x'}}
37 }... // expected-error {{does not contain any unexpanded}}
41 template<int ...a
> constexpr auto x
= [...z
= a
] (auto F
) { return F(z
...); };
42 static_assert(x
<1,2,3>([](int a
, int b
, int c
) { return 100 * a
+ 10 * b
+ c
; }) == 123);
43 static_assert(x
<1,2,3>([](int a
, int b
, int c
) { return 100 * a
+ 10 * b
+ c
; }) == 124); // expected-error {{failed}} \
44 // expected-note {{evaluates to '123 == 124'}}
46 template<int ...a
> constexpr auto y
= [z
= a
...] (auto F
) { return F(z
...); }; // expected-error {{must appear before the name of the capture}}
47 static_assert(y
<1,2,3>([](int a
, int b
, int c
) { return 100 * a
+ 10 * b
+ c
; }) == 123);
48 static_assert(y
<1,2,3>([](int a
, int b
, int c
) { return 100 * a
+ 10 * b
+ c
; }) == 124); // expected-error {{failed}} \
49 // expected-note {{evaluates to '123 == 124'}}