fork download
  1. #include <iostream>
  2. #include <complex>
  3. using namespace std;
  4.  
  5. template<typename T, decltype((T)0/(T)0)* v = nullptr>
  6. T half(T arg)
  7. {
  8. return arg/(T)2;
  9. }
  10.  
  11. string half(string arg)
  12. {
  13. return arg.substr(0, arg.length()/2);
  14. }
  15.  
  16. int main()
  17. {
  18. cout << half(2) << endl;
  19. cout << half(0.5) << endl;
  20. cout << half(complex<float>(0, 1)) << endl;
  21. cout << half(string("trivial")) << endl;
  22. return 0;
  23. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
1
0.25
(0,0.5)
tri