
6 Jul
2006
6 Jul
'06
10:28 a.m.
Martin Bonner wrote:
I think specializing std::less<> for types that don't have a natural order is /exactly/ the right way to enable such types to be stored in an associative container.
map<K, V> will work when you have less<K>, but map< pair<K, int>, V > map< pair<K, K>, V > map< vector<K>, V > sort lower_bound will not.
The algorithms are a different case. sort doesn't make sense for a type that doesn't have a natural order, and in that case the user needs to provide an appropriate comparison.
The combination of sort and lower_bound makes sense as a map replacement, although specifying less<K>() here isn't hard.