c++ – What does the code [_ = & * + [] {}] () {} () mean?

Question:

int main(void) { 
    [_=&*+[]{}](){}();
}

How to decrypt this code?

Answer:

Let's rewrite it like this

( // для красоты
    [
        _ = &*+[]{}
    ](){}
) // для красоты
(); // вызываем лямбду

Now everything will be clear, except for the contents of the square brackets – _ = &*+[]{} . This syntax came with 14 pluses . Here the underscore is the name of the variable (surprisingly). And to the right of equals is a function. The plus sign makes the usual function from the lambda . Well, the asterisk and the ampersand are mutually destroyed. Don't believe? Rewrite like this

(
    [
        _ = &*+[]{}
    ](){std::cout << typeid(_).name();}
)
();

And in case of gcc you will see PFvvE , which means void (*)()

Well, am I taken?

Scroll to Top