Why use “b < a ? a : b” instead of “a < b ? b : a” to implement max template?

std::max(a, b) is indeed specified to return a when the two are equivalent.

That’s considered a mistake by Stepanov and others because it breaks the useful property that given a and b, you can always sort them with {min(a, b), max(a, b)}; for that, you’d want max(a, b) to return b when the arguments are equivalent.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)