fork download
  1. #include <iostream>
  2.  
  3. typedef double Func (double);
  4.  
  5. double add_one (double x)
  6. {
  7. return x+1;
  8. }
  9.  
  10. template <Func Instance>
  11. struct test_type
  12. {
  13. double operator() (double x)
  14. {
  15. return Instance (x);
  16. }
  17. };
  18.  
  19. int main ()
  20. {
  21. test_type<add_one> test;
  22.  
  23. std::cout << test(10.0) << "\n";
  24.  
  25. return 0;
  26. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
11