fork download
  1. #include <algorithm>
  2.  
  3. int main() {
  4. int i = 3;
  5. double d = 3.14;
  6.  
  7. //what I want to do, which fails to compile
  8. //std::max(i, d);
  9.  
  10. //ugly
  11. std::max(static_cast<double>(i), d);
  12.  
  13. //better?
  14. std::max(i * 1.0, d);
  15. }
Success #stdin #stdout 0s 3408KB
stdin
Standard input is empty
stdout
Standard output is empty