fork download
  1. #include <cstdio>
  2.  
  3. template <typename typed> typed f() { return 2.7; }
  4. template <> int f() { return 5; }
  5. template <> double f() { return 2.3; }
  6.  
  7. struct z {
  8. template <typename T> operator T() { return f<T>(); }
  9. };
  10.  
  11. int a = z();
  12. float b = z();
  13.  
  14.  
  15. int main(void) { return !printf("%d %f", a, b); }
Success #stdin #stdout 0s 5324KB
stdin
Standard input is empty
stdout
5 2.700000