fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. template <typename T> auto f(T x) -> decltype(x*x)
  6. {
  7. return x * x;
  8. }
  9.  
  10. template <typename T> T g (T x)
  11. {
  12. return x*x;
  13. }
  14.  
  15. template <typename F> void test(F f)
  16. {
  17. auto a = f(32);
  18. auto b = f(' ');
  19. auto c = f(2000000000L);
  20.  
  21. cout << a << ' ' << b << ' ' << c << endl;
  22. }
  23.  
  24. int main()
  25. {
  26. test([](auto x){ return f(x); });
  27. test([](auto x){ return g(x); });
  28.  
  29. return 0;
  30. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
1024 1024 -1651507200
1024  -1651507200