fork(13) download
  1. #include <functional>
  2.  
  3. using namespace std;
  4.  
  5. template<typename T>
  6. struct memfun_type
  7. {
  8. using type = void;
  9. };
  10.  
  11. template<typename Ret, typename Class, typename... Args>
  12. struct memfun_type<Ret(Class::*)(Args...) const>
  13. {
  14. using type = std::function<Ret(Args...)>;
  15. };
  16.  
  17. template<typename F>
  18. typename memfun_type<decltype(&F::operator())>::type
  19. FFL(F const &func)
  20. { // Function from lambda !
  21. return func;
  22. }
  23.  
  24. template <typename... Args> void Callback(std::function<void(Args...)> f){
  25. // store f and call later
  26. }
  27.  
  28. int main()
  29. {
  30. Callback(FFL([](int a, float b){
  31. // do something
  32. }));
  33.  
  34. return 0;
  35. }
Success #stdin #stdout 0s 3424KB
stdin
Standard input is empty
stdout
Standard output is empty