fork download
  1. struct Number;
  2. struct Int {
  3. int v;
  4. operator Number();
  5. };
  6.  
  7. struct Double {
  8. double v;
  9. operator Number();
  10. };
  11.  
  12. struct Number {
  13. double v;
  14. };
  15.  
  16. Int::operator Number() { Number ret; ret.v = v; return ret; }
  17. Double::operator Number() { Number ret; ret.v = v; return ret; }
  18.  
  19. template<typename T, typename U>
  20. auto tern(bool condition, T& truereturn, U& falsereturn)->decltype(condition ? truereturn : falsereturn)
  21. {
  22. return condition ? truereturn : falsereturn;
  23. }
  24.  
  25. int main() {
  26. Int i; Double d;
  27. i.v = 0;
  28. d.v = 1.;
  29.  
  30. Number j;
  31. j = tern(i.v < d.v, i, d);
  32.  
  33. return 0;
  34. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:31:26: error: no matching function for call to 'tern(bool, Int&, Double&)'
stdout
Standard output is empty