fork download
  1. #include <iostream>
  2. #include <functional>
  3.  
  4. void f(char const*str)
  5. {
  6. std::cout << str << std::endl;
  7. }
  8.  
  9. int main()
  10. {
  11. void (*a)() (std::bind(f, "A"));
  12. void (*b)() (std::bind(f, "B"));
  13. (*a)();
  14. (*b)();
  15. (*a)();
  16. }
  17.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:11:35: error: cannot convert ‘std::_Bind_helper<false, void (&)(const char*), const char (&)[2]>::type {aka std::_Bind<void (*(const char*))(const char*)>}’ to ‘void (*)()’ in initialization
prog.cpp:12:35: error: cannot convert ‘std::_Bind_helper<false, void (&)(const char*), const char (&)[2]>::type {aka std::_Bind<void (*(const char*))(const char*)>}’ to ‘void (*)()’ in initialization
stdout

Standard output is empty