Boost logo

Boost :

From: Matthias Kaeppler (nospam_at_[hidden])
Date: 2005-03-06 12:45:13


Hello,

because of the lack of a generic adaptor which indirects operations on
pointers to the pointees, i.e. sorting a collection of pointers with
predicates applying to the pointees, I have come up with two classes,
indirecter_unary and indirecter_binary which do exactly that (thanks
again to the people from boost users and comp.lang.c++ for assisting
me). Both adaptors accept adaptable function objects as well as plain
functions.

Ex.:

inline int plus( int a, int b )
{
     return a + b;
}

// ...

std::vector<int> vec;
// ...
std::sort(vec.begin(),vec.end(),indirect_binary(std::less<int>()));
// ...
std::transform(vec.begin(),vec.end(),vec.begin(),std::ostream_iterator<int>(std::cout,"\n"),indirect_binary(plus));

I have attached the source file.

Your feedback would be greatly appreciated.

-- 
Matthias Kaeppler



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