#include <iostream>
#include <functional>
using namespace std;
template <typename F, typename S>
void doSome(F &func){
S a;
auto res = func(a);
cout << res << "\n";
}
template<>
void doSome<typename F, int> (F &func){
int a;
a = 5;
auto res = func(a);
cout << res << "\n";
}
template<>
void dpSome<typename F, double> (F &func){
double a;
a = 5.5
auto res = func(a);
cout << res << "\n";
}
int main() {
doSome([](int &a){
a += 2;
});
doSome([](double &a){
a += 2.5;
});
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8ZnVuY3Rpb25hbD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnRlbXBsYXRlIDx0eXBlbmFtZSBGLCB0eXBlbmFtZSBTPgp2b2lkIGRvU29tZShGICZmdW5jKXsKCVMgYTsKCWF1dG8gcmVzID0gZnVuYyhhKTsKCWNvdXQgPDwgcmVzIDw8ICJcbiI7Cn0KCnRlbXBsYXRlPD4Kdm9pZCBkb1NvbWU8dHlwZW5hbWUgRiwgaW50PiAoRiAmZnVuYyl7CglpbnQgYTsKCWEgPSA1OwoJYXV0byByZXMgPSBmdW5jKGEpOwoJY291dCA8PCByZXMgPDwgIlxuIjsKfQoKdGVtcGxhdGU8Pgp2b2lkIGRwU29tZTx0eXBlbmFtZSBGLCBkb3VibGU+IChGICZmdW5jKXsKCWRvdWJsZSBhOwoJYSA9IDUuNQoJYXV0byByZXMgPSBmdW5jKGEpOwoJY291dCA8PCByZXMgPDwgIlxuIjsKfQoKCmludCBtYWluKCkgewoJZG9Tb21lKFtdKGludCAmYSl7CgkJYSArPSAyOwoJfSk7CgkKCWRvU29tZShbXShkb3VibGUgJmEpewoJCWEgKz0gMi41OwoJfSk7CglyZXR1cm4gMDsKfQ==
prog.cpp:13:6: error: parse error in template argument list
void doSome<typename F, int> (F &func){
^~~~~~~~~~~~~~~~~~~~~~~
prog.cpp:13:31: error: template-id ‘doSome<<expression error> >’ used as a declarator
void doSome<typename F, int> (F &func){
^
prog.cpp:13:31: error: variable or field ‘doSome’ declared void
prog.cpp:13:31: error: ‘F’ was not declared in this scope
prog.cpp:13:34: error: ‘func’ was not declared in this scope
void doSome<typename F, int> (F &func){
^~~~
prog.cpp:21:12: error: expected initializer before ‘<’ token
void dpSome<typename F, double> (F &func){
^
prog.cpp: In function ‘int main()’:
prog.cpp:32:3: error: no matching function for call to ‘doSome(main()::<lambda(int&)>)’
});
^
prog.cpp:6:6: note: candidate: template<class F, class S> void doSome(F&)
void doSome(F &func){
^~~~~~
prog.cpp:6:6: note: template argument deduction/substitution failed:
prog.cpp:32:3: note: couldn't deduce template parameter ‘S’
});
^
prog.cpp:36:3: error: no matching function for call to ‘doSome(main()::<lambda(double&)>)’
});
^
prog.cpp:6:6: note: candidate: template<class F, class S> void doSome(F&)
void doSome(F &func){
^~~~~~
prog.cpp:6:6: note: template argument deduction/substitution failed:
prog.cpp:36:3: note: couldn't deduce template parameter ‘S’
});
^