Using std :: bind to bind the result with another std :: bind as an argument

I need to grab the binding object just to move to a lambda, and I am trying to use a workaround using std :: bind to get the move capture semantics from C ++ 11 as verbose. I've scaled down a test case that shows that the motion-only part is irrelevant to the compilation error I'm facing, so in general this question is about using std :: bind to bind the result from another std :: bind as an argument .

Here's a minimal example from more complex code:

void g(int);

void test() {
    auto fn = std::bind(g, 0);
    using Fn = decltype(fn);
//    auto bound = [fn] {};
    auto bound = std::bind([] (Fn) {}, fn);
    bound();
}

      

This results in the error "There is no corresponding function to call" __invoke. "The full error output is available here .

The equivalent simpler case using a grabbing lambda (remembered in the code above) works fine, of course. But in my actual code, I would need to write [fn = std::move(fn)] {}

and I don't have the option of restarting C ++ 14 yet.

What am I doing wrong?

+3


source to share





All Articles