Boost logo

Boost :

From: Lewis Hyatt (lhyatt_at_[hidden])
Date: 2007-03-19 10:03:47

> * provide an easy way to sort lists of pointers (without having to make
> a custom '<' operator each time).

this is already in boost:

some_iterator begin, end;
std::sort(boost::indirect_iterator(begin), boost::indirect_iterator(end));

* Easy way to specify different
> comparison operators for various subfields. ie. in stead of one complex
> '<' operator, specify one for each subfield and then define sortorder
> (which subfield first, ...) on sorttime.

This is an intriguing possibility, what about some intrusive design, where you
can tag class members as sort keys?

> * provide a good set of default '<' operators. at least:
> - simple types (strings, numbers, ...)
> - pointers to simple types
> - pairs of the above

Simple types and pairs already have operator<, and pointers are handled by

> * Specify ascending vs. descending sorting. Trivial criteria really, but
> reduces complexity (or number) of the '<' operators.

std::sort(begin, end, std::greater<type>());

> * return the n highest/lowest only. (optimized, ie: not full sort and
> then cutting solution)



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