fork download
  1. #include <functional>
  2. #include <iostream>
  3.  
  4. template<typename T>
  5. void func_a(int a, T t)
  6. {
  7. std::cout << "I'm called first" << std::endl;
  8. t();
  9. }
  10.  
  11. template<typename T>
  12. void func_b(T t)
  13. {
  14. t();
  15. }
  16.  
  17. template<typename T>
  18. void func_c(T t)
  19. {
  20. func_b(std::bind(func_a<T>, 1, t));
  21. }
  22.  
  23. template<typename T>
  24. void func(T a) { }
  25.  
  26. int main()
  27. {
  28. func_c(std::bind(func<int>, 1));
  29. return 0;
  30. }
  31.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'void func_b(T) [with T = std::_Bind<void (*(int, std::_Bind<void (*(int))(int)>))(int, std::_Bind<void (*(int))(int)>)>]':
prog.cpp:20:2:   instantiated from 'void func_c(T) [with T = std::_Bind<void (*(int))(int)>]'
prog.cpp:28:32:   instantiated from here
prog.cpp:14:2: error: conversion from 'std::result_of<const std::_Bind<void (*())()>()>::type' to non-scalar type 'std::_Bind<void (*(int))(int)>' requested
prog.cpp:20:2:   instantiated from 'void func_c(T) [with T = std::_Bind<void (*(int))(int)>]'
prog.cpp:28:32:   instantiated from here
prog.cpp:14:2: error: conversion from 'std::result_of<std::_Bind<void (*())()>()>::type' to non-scalar type 'std::_Bind<void (*(int))(int)>' requested
prog.cpp:14:2: error: no match for call to '(std::_Bind<void (*(int, std::_Bind<void (*(int))(int)>))(int, std::_Bind<void (*(int))(int)>)>) ()'
stdout
Standard output is empty