
Sean Parent wrote:
From item 6 - I'd remove the operator < from shared_ptr. If we were going to keep operator < for shared ptr, then I would have to argue to change all of the examples from 6 for consistency (or provide a semantic difference between shared_ptr and these cases.
There are two problems with using std::less instead of operator< to supply a set/map order. First, it doesn't propagate to composite types; if you provide a specialization of less<K>, less< pair<K, int> > doesn't work. Second, less<K> is defined as always using K::operator< unless K is a raw pointer; it is basically a different name for operator<, one that can be used as a predicate. This gives rise to the interpretation that wherever less<K> is encountered, the implementation is entitled to use K::operator< directly. This could have been avoided by defining a separate relation for set/map order, either as a function reachable via ADL, or as a function object, then making sure that it is defined for all standard value types. With suitable changes to the standard, less<K> can be made that relation, and if this happens, shared_ptr ought to also be changed to reflect that.