Boost logo

Boost :

From: Joe Gottman (jgottman_at_[hidden])
Date: 2005-09-14 20:40:50


"Loïc Joly" <loic.actarus.joly_at_[hidden]> wrote in message
news:4328907E.8050606_at_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


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk