I'm having trouble in a part of my program where I pass an object that acts as a lambda function to another function (I need to capture a const this pointer so I can't use an actual lambda). This causes the copy constructor of my lambda to be called, which again calls the copy constructor, and eventually the stack overflows. I understand what's happening but I'm not sure why the copy constructor is calling itself or how to fix this. I've reproduced the problem below.
Compiler: MSVC 2010
#include <functional>
void synchronizedExecution(std::function<void()> function) {
    function();
}
int main(int argc, char *argv[])
{
    int b = 0;
    class Function : public std::function<void()> {
    public:
        int& b;
        Function(int& b) :
            b(b) {}
        void operator()() {}
    } function(b);
    synchronizedExecution(function);
    return 0;
}
 
     
    