fork(1) download
  1. #include <iostream>
  2. #include <functional>
  3. #include <sstream>
  4. #include <vector>
  5. using namespace std;
  6.  
  7. int f1(int x) {
  8. }
  9.  
  10. string f2(int x) {
  11. }
  12.  
  13. long long f3(int x) {
  14. }
  15.  
  16. template<class T>
  17. function<string(int)> conv(function<T(int)> f) {
  18. return [&](int x) -> string {
  19. stringstream ss;
  20. ss << f(x);
  21. return ss.str();
  22. };
  23. }
  24.  
  25. int main() {
  26.  
  27. vector<function<string(int)>> funcs = {
  28. conv(f1),
  29. };
  30.  
  31. return 0;
  32. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:8:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
prog.cpp:11:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
prog.cpp:14:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
prog.cpp:28:3: error: no matching function for call to 'conv'
                conv(f1),
                ^~~~
prog.cpp:17:23: note: candidate template ignored: could not match 'function<type-parameter-0-0 (int)>' against 'int (*)(int)'
function<string(int)> conv(function<T(int)> f) {
                      ^
3 warnings and 1 error generated.
stdout
Standard output is empty