I'm asking you a question because I saw such a strange code.
I don't know why ([](){})());
is compiled normally in the source code below
I'm not a function pointer, I'm not an operator.
But if you run it on Visual Studio 2010, nothing comes out...
What is that doing?
int main(){
(([](){})()); // ??????
}
That code is called empty lambda
.
I don't really do anything.
First, [](){}
is empty lambda expression
.
For convenience, let 1 = [](){}
and (([](){})();
= ((A)();
.
Second, parentheses expression
in C/C++ have no effect on the code.
It does the same thing, whether it's in parentheses or not.
So you know up to here (A)
= A
.
Let's say B
= (A)
and ((A)();
= (B());
.
Third, ()
is (empty)
lambda
.
Then let's say C
= B()
and (B();
= (C);
.
(C)
is parentheses the entire expression
as we did in the second.
Then D
= (C)
and (C);
= D;
.
Lastly. ;
is the role to end a sentence.
© 2024 OneMinuteCode. All rights reserved.