News for hackers. Stuff that matters.
Re:The joy of max() by loeg on Friday March 30, 2018 @11:25PM (#16721511)
The C version works with distinct types for a and b. Does this?
Re:The joy of max() by Jyaif on Saturday March 31, 2018 @02:25AM (#16722043)
That's not a feature, it's more bug prone.
Re:The joy of max() by andrepd on Saturday March 31, 2018 @05:48AM (#16722597)
This one works too, if they are implicitly convertible (e.g. max(1, 2.0))
Re:The joy of max() by bstamour on Saturday March 31, 2018 @08:10AM (#16722957)
No it won't. You'll get a compile time error, as T could either deduce to int or double. Unless you explicitly specify it as max<int>(1, 2.0) or max<double>(1, 2.0).