Many times I needed a set of pointers. Every time that happens, I end up writing a less<> implementation for a pointer type - cast two pointers to size_t and compare the results.
My question is - is that available in the standard? I could not find anything like that. Seems like common enough case...
Update: it seems that the upcoming standard fixes all of the problems with less<> provided for pointer types and unordered_set included, too. In a few years this question will be moot.
In the mean time, the current standard has no "legal" solution to this, but size_t cast works.
Update for update: well, I'll be gobsmacked! Not only
std::map<void *, int, std::less<void*> > myMap;
works, but even
std::map<void *, int > myMap;
as well.
And that's in gcc 3.4.1 . I've been doing all the these casts for nothing, and litb is perfectly right. Even the section number he cites is exactly the same in the current standard. Hurray!
lesssolution is the one of the current standard. It's not C++0x specific - Johannes Schaub - litb