p23.cpp revision a73652465bcc4c0f6cb7d933ad84e002b527a643
1// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
2
3void print();
4
5template<typename T, typename... Ts>
6void print(T first, Ts... rest) {
7  (void)first;
8  print(rest...);
9}
10
11template<typename... Ts>
12void unsupported(Ts ...values) {
13  auto unsup = [values] {}; // expected-error{{unexpanded function parameter pack capture is unsupported}}
14}
15
16template<typename... Ts>
17void implicit_capture(Ts ...values) {
18  auto implicit = [&] { print(values...); };
19  implicit();
20}
21
22template<typename... Ts>
23void do_print(Ts... values) {
24  auto bycopy = [values...]() { print(values...); };
25  bycopy();
26  auto byref = [&values...]() { print(values...); };
27  byref();
28
29  auto bycopy2 = [=]() { print(values...); };
30  bycopy2();
31  auto byref2 = [&]() { print(values...); };
32  byref2();
33}
34
35template void do_print(int, float, double);
36
37template<typename T, int... Values>
38void bogus_expansions(T x) {
39  auto l1 = [x...] {}; // expected-error{{pack expansion does not contain any unexpanded parameter packs}}
40  auto l2 = [Values...] {}; // expected-error{{'Values' in capture list does not name a variable}}
41}
42
43void g(int*, float*, double*);
44
45template<class... Args>
46void std_example(Args... args) {
47  auto lm = [&, args...] { return g(args...); };
48};
49
50template void std_example(int*, float*, double*);
51
52template<typename ...Args>
53void variadic_lambda(Args... args) {
54  auto lambda = [](Args... inner_args) { return g(inner_args...); };
55  lambda(args...);
56}
57
58template void variadic_lambda(int*, float*, double*);
59