Using C++11 lambdas asynchronously, safely

后端 未结 3 1369
失恋的感觉
失恋的感觉 2021-01-31 11:06

I\'ve come to C++11 from an Objective-C background, and one thing I\'m struggling to come to terms with is the different capturing semantics of C++11 lambdas vs Objective-C \"bl

3条回答
  •  鱼传尺愫
    2021-01-31 11:31

    Boost uses:

    auto self(shared_from_this());
    auto l = [this, self] { do(); };
    

    Mentioned here: What's the reason of using auto self(shared_from_this()) variable in lambda function?

提交回复
热议问题