fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. template<typename T1, typename T2>
  5.  
  6. auto add(T1 a, T2 b) -> decltype((a==1)?a:b){
  7. if(a == 1)
  8. return a;
  9. else
  10. return b;
  11. }
  12.  
  13. int main() {
  14. // your code goes here
  15. cout << add(1,1.8) << endl;
  16. cout << add(2,1.1) << endl;
  17. return 0;
  18. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
1
1.1