Share variable between two lambdas
问题 I want to be able to share a variable in the containing scope between two lambda functions. I have the following: void holdAdd(const Rect& rectangle, Hold anonymousHeld, Hold anonymousFinish) { std::map<int,bool> identifierCollection; HoldFinish holdFinish = [=](const int& identifier) mutable { if (identifierCollection.count(identifier) == 0) return; identifierCollection.erase(identifier); anonymousFinish(); }; holdCollisionCollection.push_back([=](const int& identifier, const Vec2& point)