fork(1) download
  1. #include <iostream>
  2.  
  3. template <typename T>
  4. T default_construct() { return T{}; }
  5.  
  6. template <typename T, T(INIT)() = &default_construct<T>>
  7. struct Foo
  8. {
  9. T value = INIT();
  10. };
  11.  
  12. int bar() { return 42; }
  13.  
  14. int main()
  15. {
  16. Foo<int> f;
  17. Foo<int, bar> b;
  18.  
  19. std::cout << f.value << std::endl;
  20. std::cout << b.value << std::endl;
  21. }
  22.  
  23.  
Success #stdin #stdout 0s 3140KB
stdin
Standard input is empty
stdout
0
42