Boost logo

Boost :

From: Dave Abrahams (abrahams_at_[hidden])
Date: 2000-06-08 16:21:25

--- In boost_at_[hidden], Gary Powell <Gary.Powell_at_s...> wrote:
> > How often have you written an aggregate class from which you
> > to use all or some data members to form a sort key for a standard
> > container or algorithm? Happens to me all the time. As such, I
> > propose the following suite of template functions as an addition
> > utility.hpp (please, someone, suggest a better name!)
> >
> Alternatively to the pair suggestion, you could use Jaakko
Jarvi's "tuples".
> It doesn't have a global operator<(tuple,tuple) but we could add it
> enough.

Good thoughts, but the pair idea and tuples both have serious
usability problems outside the context of comparison. In my
particular case I'm trying to make a sort key out of a 'C' struct
which was defined externally, and of course pair/tuple are completely
useless there. I suppose I might try comparing tuples of references,
though... is there a bind() function (or some such) which will
produce these?
Lastly, I've been thinking that the ideal facility would allow the
user to choose the comparison operator/functor for each element being
compared (i.e. you might use std::less on the first element but
std::greater on the 2nd).


Boost list run by bdawes at, gregod at, cpdaniel at, john at