From: Gary Powell (Gary.Powell_at_[hidden])
Date: 2001-05-24 12:07:45
> Having said that, the reason std::less is provided is to allow
> to be used as keys for maps. Again, shared_ptr reflects the Standard
> which defines std::less for *all* pointers (not just pointing into the
Actually having used that feature, a map with keys as smart pointers, I
found that it didn't work, and I had to write a helper class which would
force the map to evaluate the contents of the smart pointers as the keys.
(Also if you do this (use shared pointers as keys), for me its fine for
insertion, but sucks for lookup, because you have to create a new smart
pointer if the key doesn't come from some other container of said smart
pointers. I ended up tossing it as it became an ugly mess of helper classes,
allocations etc. The size savings wasn't worth the runtime penalty.
So I would actually prefer that shared pointers NOT have std::less<>
1) because it rarely makes sense to compare two pointers for a map.
2) The lack of the overload would force the programmer to decide what they
actually wanted instead of the silent compile and generally wrong result.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk