If an object has operator<() it has a well-defined ordering. If it doesn't, you can consider it to not to have one. And, um, that's it.
Using it for string lexicographical ordering isn't an abuse, and I can't imagine it actually confusing anyone unless they get confused a lot.
(Whether containers that internally require an ordering should be able to work with types that don't have a well-defined ordering is a good question - but I'm unclear on what it would mean to have an ordered container full of things that don't have a well-defined ordering, so hiding a "No, we really mean this comparator function" that's not operator<() seems like it'd add confusion rather than reduce it).
3
u/lluad Aug 08 '14 edited Aug 08 '14
If an object has operator<() it has a well-defined ordering. If it doesn't, you can consider it to not to have one. And, um, that's it.
Using it for string lexicographical ordering isn't an abuse, and I can't imagine it actually confusing anyone unless they get confused a lot.
(Whether containers that internally require an ordering should be able to work with types that don't have a well-defined ordering is a good question - but I'm unclear on what it would mean to have an ordered container full of things that don't have a well-defined ordering, so hiding a "No, we really mean this comparator function" that's not operator<() seems like it'd add confusion rather than reduce it).