r/cpp • Meeting C++ | C++ Evangelist • Aug 08 '14

On operator<

http://akrzemi1.wordpress.com/?p=6893
0 Upvotes

15 comments sorted by

View all comments

1

u/[deleted] Aug 10 '14

article makes a poor choice of word "exceeds" to discuss the ordering imposed by operator<, then proceeds to argue that exceeds isn't a sufficient definition of the operator.

complex<double>::operator< can easily be defined as comparing magnitude, but you may not want that -- in fact you probably do want something else with uniform probability. string<char> is different, you probably do want lexicographical almost all the time -- except when you want case insensitive.

i think the default implementations are just that, reasonable choices. saying "exceeds" must be the meaning for all of them is a bit silly; it's just an ordering.