fork download
  1. #include <iostream>
  2. #include <functional>
  3. using namespace std;
  4.  
  5. class X
  6. {
  7. static std::function<void()> f;
  8. public:
  9. template<typename T = decltype(f)>
  10. void test(T fn = f){
  11. fn();
  12. }
  13. };
  14.  
  15. std::function<void()> X:: f = []{};
  16. int main() {
  17.  
  18.  
  19. X xx;
  20.  
  21. auto l =[]{std::cout << "Hello POW" <<std::endl ;};
  22. xx.test(l);
  23. xx.test();
  24. return 0;
  25. }
Success #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
Hello POW