#include <iostream>
#include <functional>
#include <memory>
using namespace std;
struct connection;
struct login;
struct huin;
typedef shared_ptr<connection> connection_ptr;
typedef shared_ptr<login> login_ptr;
typedef shared_ptr<huin> huin_ptr;
void on_message(const connection_ptr& , const login_ptr message ) {
}
void on_message(const connection_ptr& , const huin_ptr message ) {
}
template<class T>
void register_yoba( const function<void(const connection_ptr&, const shared_ptr<T>)> f ) {
}
int main() {
register_yoba<login>(&on_message);
register_yoba<huin>(&on_message);
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8ZnVuY3Rpb25hbD4KI2luY2x1ZGUgPG1lbW9yeT4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnN0cnVjdCBjb25uZWN0aW9uOwpzdHJ1Y3QgbG9naW47CnN0cnVjdCBodWluOwoKdHlwZWRlZiBzaGFyZWRfcHRyPGNvbm5lY3Rpb24+IGNvbm5lY3Rpb25fcHRyOwp0eXBlZGVmIHNoYXJlZF9wdHI8bG9naW4+IGxvZ2luX3B0cjsKdHlwZWRlZiBzaGFyZWRfcHRyPGh1aW4+IGh1aW5fcHRyOwoKCnZvaWQgb25fbWVzc2FnZShjb25zdCBjb25uZWN0aW9uX3B0ciYgLCBjb25zdCBsb2dpbl9wdHIgbWVzc2FnZSApIHsKfQoKdm9pZCBvbl9tZXNzYWdlKGNvbnN0IGNvbm5lY3Rpb25fcHRyJiAsIGNvbnN0IGh1aW5fcHRyIG1lc3NhZ2UgKSB7Cn0KCgp0ZW1wbGF0ZTxjbGFzcyBUPgp2b2lkIHJlZ2lzdGVyX3lvYmEoIGNvbnN0IGZ1bmN0aW9uPHZvaWQoY29uc3QgY29ubmVjdGlvbl9wdHImLCBjb25zdCBzaGFyZWRfcHRyPFQ+KT4gZiApIHsKCgkKfQoKCmludCBtYWluKCkgewoJcmVnaXN0ZXJfeW9iYTxsb2dpbj4oJm9uX21lc3NhZ2UpOwoJcmVnaXN0ZXJfeW9iYTxodWluPigmb25fbWVzc2FnZSk7CglyZXR1cm4gMDsKfQ==
prog.cpp: In function ‘int main()’:
prog.cpp:30:34: error: no matching function for call to ‘register_yoba<login>(<unresolved overloaded function type>)’
register_yoba<login>(&on_message);
^
prog.cpp:23:6: note: candidate: ‘template<class T> void register_yoba(std::function<void(const std::shared_ptr<connection>&, std::shared_ptr<_Tp>)>)’
void register_yoba( const function<void(const connection_ptr&, const shared_ptr<T>)> f ) {
^~~~~~~~~~~~~
prog.cpp:23:6: note: template argument deduction/substitution failed:
prog.cpp:30:23: note: cannot convert ‘& on_message’ (type ‘<unresolved overloaded function type>’) to type ‘std::function<void(const std::shared_ptr<connection>&, std::shared_ptr<login>)>’
register_yoba<login>(&on_message);
^~~~~~~~~~~
prog.cpp:31:33: error: no matching function for call to ‘register_yoba<huin>(<unresolved overloaded function type>)’
register_yoba<huin>(&on_message);
^
prog.cpp:23:6: note: candidate: ‘template<class T> void register_yoba(std::function<void(const std::shared_ptr<connection>&, std::shared_ptr<_Tp>)>)’
void register_yoba( const function<void(const connection_ptr&, const shared_ptr<T>)> f ) {
^~~~~~~~~~~~~
prog.cpp:23:6: note: template argument deduction/substitution failed:
prog.cpp:31:22: note: cannot convert ‘& on_message’ (type ‘<unresolved overloaded function type>’) to type ‘std::function<void(const std::shared_ptr<connection>&, std::shared_ptr<huin>)>’
register_yoba<huin>(&on_message);
^~~~~~~~~~~