fork(3) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. typedef void (*F)();
  5.  
  6. template<F f> struct Goal
  7. {
  8. Goal() { f(); }
  9. };
  10.  
  11. template<F f> struct Singleton
  12. {
  13. static Goal<f> instance;
  14. };
  15. template<F f> Goal<f> Singleton<f>::instance;
  16.  
  17. template<F f, Goal<f>* I> struct Instantiator {};
  18.  
  19. template<F f> struct Voila : Instantiator<f, &Singleton<f>::instance> {};
  20.  
  21. void foo() { cout << "foo" << endl; }
  22. Voila<foo> voici;
  23.  
  24. int main() {
  25. // your code goes here
  26. return 0;
  27. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
foo