fork download
  1. void foo(const int *n) { }
  2.  
  3. template <typename ...Args>
  4. void bar(void (*func)(Args...), Args... args) { func(args...); }
  5.  
  6. int main(int argc, char *argv[])
  7. {
  8. int n = 42;
  9. bar(foo, &n);
  10. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main(int, char**)’:
prog.cpp:9:16: error: no matching function for call to ‘bar(void (&)(const int*), int*)’
     bar(foo, &n);
                ^
prog.cpp:4:6: note: candidate: template<class ... Args> void bar(void (*)(Args ...), Args ...)
 void bar(void (*func)(Args...), Args... args) { func(args...); }
      ^~~
prog.cpp:4:6: note:   template argument deduction/substitution failed:
prog.cpp:9:16: note:   inconsistent parameter pack deduction with ‘const int*’ and ‘int*’
     bar(foo, &n);
                ^
stdout
Standard output is empty