News for hackers. Stuff that matters.
Re:The joy of max() by mehrdadn on Friday March 30, 2018 @09:14PM (#16721077)
Edit: apologies, I'm blind; never mind. I thought I double-checked but the use of > instead of < tripped me up.
Re:The joy of max() by darkmx0z on Friday March 30, 2018 @09:57PM (#16721222)
Stepanov disagrees. You should return the second parameter if a, b are equivalent (and you should use < anyway):

  template<typename T>
  inline constexpr const T& max(const T& a, const T& b) {
     return (b < a ? a : b);
  }
Re:The joy of max() by a_t48 on Saturday March 31, 2018 @03:27AM (#16722221)
What’s the reasoning behind this?
Re:The joy of max() by enitihas on Saturday March 31, 2018 @03:41AM (#16722252)
I think to be comparable in c++ types are required to implement < operator and the same is exclusively used by the stdlib.
Re:The joy of max() by darkmx0z on Saturday March 31, 2018 @11:41AM (#16723720)
If you sort2(a, b), it would be nice if min(a, b) == a && max(a, b) == b.