| 1 |
// P0806R2 |
| 2 |
// { dg-do compile } |
| 3 |
// { dg-options "-std=c++2a -Wno-deprecated" } |
| 4 |
|
| 5 |
struct X { |
| 6 |
int x; |
| 7 |
void foo (int n) { |
| 8 |
auto a1 = [=] { x = n; }; // { dg-bogus "implicit capture" } |
| 9 |
auto a2 = [=, this] { x = n; }; |
| 10 |
auto a3 = [=, *this]() mutable { x = n; }; |
| 11 |
auto a4 = [&] { x = n; }; |
| 12 |
auto a5 = [&, this] { x = n; }; |
| 13 |
auto a6 = [&, *this]() mutable { x = n; }; |
| 14 |
|
| 15 |
auto a7 = [=] { // { dg-bogus "implicit capture" } |
| 16 |
auto a = [=] { // { dg-bogus "implicit capture" } |
| 17 |
auto a2 = [=] { x = n; }; // { dg-bogus "implicit capture" } |
| 18 |
}; |
| 19 |
}; |
| 20 |
|
| 21 |
auto a8 = [=, this] { |
| 22 |
auto a = [=, this] { |
| 23 |
auto a2 = [=, this] { x = n; }; |
| 24 |
}; |
| 25 |
}; |
| 26 |
|
| 27 |
auto a9 = [=, *this]() mutable { |
| 28 |
auto a = [=, *this]() mutable { |
| 29 |
auto a2 = [=, *this]() mutable { x = n; }; |
| 30 |
}; |
| 31 |
}; |
| 32 |
|
| 33 |
auto a10 = [&] { |
| 34 |
auto a = [&] { |
| 35 |
auto a2 = [&] { x = n; }; |
| 36 |
}; |
| 37 |
}; |
| 38 |
|
| 39 |
auto a11 = [&, this] { |
| 40 |
auto a = [&, this] { |
| 41 |
auto a2 = [&, this] { x = n; }; |
| 42 |
}; |
| 43 |
}; |
| 44 |
|
| 45 |
auto a12 = [&, *this]() mutable { |
| 46 |
auto a = [&, *this]() mutable { |
| 47 |
auto a2 = [&, *this]() mutable { x = n; }; |
| 48 |
}; |
| 49 |
}; |
| 50 |
} |
| 51 |
}; |