阅读背景:

为什么一般的lambda不能调用自己,但将它包装在类中允许它?

来源:互联网 

Here is the full example:

这是完整的例子:

auto callSelf = [](auto& func) {func(func);};

class wrapper : public decltype(callSelf) {
    using base = decltype(callSelf);
public:
    wrapper() : base(callSelf) {}

    template<class T>
    void operator()(T& func) {
        base::operator()(func);
    }
};

int main()
{
    //callSelf(callSelf); // Error
    wrapper w;
    w(w); // OK, nice endless recursion
}
auto cal



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: