Saturday, 31 August 2013

Lambda function passed in constructor of new pointer needs access to the object

Lambda function passed in constructor of new pointer needs access to the
object

I have the following code:
class A
{
protected:
int a
public:
std::function<void()> lambdaFunc;
A(std::function<void()> lambdaParam) : lambdaFunc(lambdaParam){}
};
int main()
{
someFunctionCall(std::shared_ptr<A>(new A([](){ /*I need this to
access int a*/ }));
}
I'm not sure how I can give the lambda function in this instance access to
the new object?

No comments:

Post a Comment