max()
template according to Stepanov Notes intentionally return
b<a?a:b
instead of
a<b?b:a
to ensure that the function behaves correctly even if the two values are equivalent but not equal Few explanations over here but still couldn't understand http://stepanovpapers.com/notes.pdf (page 63)
I am not able to think of a use case when two values will be equivalent but not equal
when a==b
first returns b
, second returns a
This would triggers when you overload a class's <
function
e.g.
class myClass {
public:
int key;
string value;
bool operator<(const myClass& rhs) {
return this->key < rhs.key;
}
}
You may need to decide what do you want your program do in a more specific case
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With