Advertisement
Guest User

Untitled

a guest
Apr 25th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. auto dummy_lambda = []{};
  4. using lambda_type = decltype(dummy_lambda);
  5.  
  6. template<typename F1, typename F2 = lambda_type const&>
  7. void foo(F1&& f1, F2&& f2 = dummy_lambda)
  8. {
  9. std::forward<F1>(f1)();
  10. std::forward<F2>(f2)();
  11. }
  12.  
  13.  
  14. void bar()
  15. {
  16. std::cout << "hello!\n";
  17. }
  18.  
  19. int main(int, const char*[])
  20. {
  21. foo(&bar, &bar);
  22. foo(&bar);
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement