无法理解这段代码的含义

Not able to understand the meaning of this code

我不明白下面的代码在做什么

auto sgn = [&](int x) 
{
        if (x > 0) return 1;
        else return -1;
};

& 符号在这里的作用是什么?它是一个指针吗?这个块是结构还是类似的东西?

我在 codeforces round 636 division 3 社论中看到了这段代码。

这里的&表示lambda通过引用捕获所有变量。

lambda returns 1-1 取决于参数 x 的值,因此捕获在这里实际上并不重要。