template argument deduction/substitution failed, when using std::function and std::bind

To figure out the problem let separate statements:

auto f = bind(&TestA::testa, &testA, _1, _2); // OK
test.setCallback(f);                          // <<--- Error is here

setCallback needs to know type of T and it can’t deduce it from f, so give it a type

test.setCallback<TYPE>(f); // TYPE: int, float, a class, ...

Leave a Comment