Boost logo

Boost :

From: Maciej Sobczak (maciej_at_[hidden])
Date: 2002-07-25 02:02:32


Hi Boosters,

Victor A. Wagner, Jr. wrote:
> I've noticed in our coding, we sometimes need a comparison operator that
> works on just a single element in a struct, instead of the "entire
> struct". If we need to sort the container using just this "key"; we, of
> course, write the comparison function/functor and then:
[snip]
> I decided to write a couple templates and helper functions called (the
> ones you'd use) less_element() and greater_element().

It is not very flexible.
What about function objects that are not yet invented?

Some time ago I wrote the adaptor class that allows you to wrap
*arbitrary* functor (less, greater, etc.) in a uniform manner:

http://www.maciejsobczak.com/prog/snippets.html

(please scroll down the page to the third example - the others are used
by me in flame wars with Java extremists ;-) and are not relevant here)

Cheers,

Maciej Sobczak
http://www.maciejsobczak.com/


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