I need to capture a move-only bind object in a lambda, and I'm trying to use a workaround with std::bind to obtain move-capturing semantics with C++11 as detailed here. I've reduced a test case that shows the move-only part of it isn't relevant to the compile error I'm encountering, so most generally this question is about using std::bind to bind the result from another std::bind as an argument.
Here's a minimal example reduced 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 produces the error "No matching function for call to '__invoke'". The complete error output is available here.
The equivalent simpler case using a capturing lambda (commented out in the above code) 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 requring C++14 yet.
What am I doing wrong?