#include <cstdio>
#include <functional>
template<class T>
void test(T t, std::function<void(T)> f) { f(t); }
//void test(T t, std::function<void(int)> f) { f(t); }
void PrintIt(int v){ printf("V=%d\n", v); };
int main(int argc, char *argv[]) {
test(5, PrintIt);
}
I2luY2x1ZGUgPGNzdGRpbz4KI2luY2x1ZGUgPGZ1bmN0aW9uYWw+CnRlbXBsYXRlPGNsYXNzIFQ+CnZvaWQgdGVzdChUIHQsIHN0ZDo6ZnVuY3Rpb248dm9pZChUKT4gZikgeyBmKHQpOyB9Ci8vdm9pZCB0ZXN0KFQgdCwgc3RkOjpmdW5jdGlvbjx2b2lkKGludCk+IGYpIHsgZih0KTsgfQoKdm9pZCBQcmludEl0KGludCB2KXsgcHJpbnRmKCJWPSVkXG4iLCB2KTsgfTsKCgppbnQgbWFpbihpbnQgYXJnYywgY2hhciAqYXJndltdKSB7CiAgICB0ZXN0KDUsIFByaW50SXQpOwp9Cg==
prog.cpp: In function 'int main(int, char**)':
prog.cpp:11:20: error: no matching function for call to 'test(int, void (&)(int))'
test(5, PrintIt);
^
prog.cpp:11:20: note: candidate is:
prog.cpp:4:6: note: template<class T> void test(T, std::function<void(T)>)
void test(T t, std::function<void(T)> f) { f(t); }
^
prog.cpp:4:6: note: template argument deduction/substitution failed:
prog.cpp:11:20: note: mismatched types 'std::function<void(T)>' and 'void (*)(int)'
test(5, PrintIt);
^