
"Loïc Joly" <loic.actarus.joly@numericable.fr> wrote in message news:4328907E.8050606@numericable.fr...
Hello everybody,
Often , when someone creates a collection of smart_ptr, he wants the collection to be sorted by objects, and not by pointer adresses (this is what is used for instance in ptr_containers). To do that, one can provide his functor to the container/algorithm required, but this is burdensome.
I do not think that modifying the current behaviour of smart pointers to make the comparison of smart pointers compare objet would be a good idea (even in cases it is possible to compare by objects, people who do not need this sorting would be impacted by the performances of sorting by objects). However, since this a quite a common thing to do, I wonder wether such a functor could be provided inside the smart_ptr headers, so that people who want to use this option can use it directly.
This functionality is already available in <boost/utility/compare_pointees.hpp>. There are two functions, equal_pointees() and less_pointees(), and two corresponding classes, equal_pointees_t and less_pointees_t. Joe Gottman