| 1 |
// N3648: capture init example from paper |
| 2 |
// { dg-do run { target c++14 } } |
| 3 |
|
| 4 |
int x = 4; |
| 5 |
auto y = [&r = x, x = x+1]()->int { |
| 6 |
r += 2; |
| 7 |
return x+2; |
| 8 |
}(); // Updates ::x to 6, and initializes y to 7. |
| 9 |
|
| 10 |
int main() |
| 11 |
{ |
| 12 |
if (x != 6 || y != 7) __builtin_abort(); |
| 13 |
} |