Possible Duplicate:
Parentheses at the end of a C++11 lambda expression
#include <iostream>
int main(int argc, char* argv[])
{
int j;
[&](){j = 10;}(); // why I need the last rounded parentheses () and what is their purpose ?
// ...
return(0);
}
I get almost everything about how the lambda works, my last question is about why i need the last couple of parentheses like reported in the above code.
The blueprint for a lambda is
[](){}
Also, I'm taking an input for my lambda by reference here, I'm directly writing into j
with this lambda, but my compiler complains about the fact that this lambda generates an unused value if i don't put the extra ()
at the end of the lambda.
So, in the end, a lambda is this
[](){}
or this
[](){}()
?