I recently came across the following esoteric piece of code.
int main(){(([](){})());}
Reformat it as follows to make it more readable:
int main(){
(([](){})()); // Um... what?!?!
}
But I can't get my head around how (([](){})())
is valid code.
- It doesn't look like function pointer syntax.
- It can't be some operator overloading trick. The code compiles as is.
Google didn't help much with this all-symbol search. But it compiles in Visual Studio 2010 and outputs nothing. There were no errors, and no warnings. So it looks like valid code.
I've never seen any valid code that is so bizarre outside of Javascript and C function pointers.
Can someone explain how this is valid C++?
Don't sweat it. We have int main(){(([](){})());} which is valid C++"
(Nov 9th in chat) – sehe