Someone asked me why this code does not compile:
int main() { int a = 0; int x = 3, y = 2, z = 1; auto f = [&a,=]() { a = x + y + z; }; f(); }
I checked in Visual Studio 2017 and wandbox for gcc HEAD 8.0.0 201708 and it is true, it does not compile.
First gcc error:
error: expected identifier before '=' token
in line with lambda and it complains about = in the capture clause.
What is wrong with the code?
c ++ c ++ 11
Kate gregory
source share