Is it possible to extract the capture list of a lambda?

Viewed 795

From this link here I understand that inorder to pass a lambda we need to pass the method as a parameter and to store it in a std::function type. In such case, is it possible to extract the parameters from a capture list of a lambda?

example

struct foo
{
    std::vector<int> t = {1,2,3};
};

void funct(std::function<void()> func)
{
    func(); //This works fine . Can I extract the object foo from this lambda ?
}

int main()
{
   foo a;
   a.t.push_back(45);
   funct( [a](){ std::cout << "New value is " << a.t[3] ; } );
}
2 Answers
Related