|
Boost : |
From: Gary Powell (Gary.Powell_at_[hidden])
Date: 2000-06-08 17:06:14
> In my
> particular case I'm trying to make a sort key out of a 'C' struct
> which was defined externally,
>
> 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).
>
So the part I don't get is, why not write the global
operator>(Cstruct,Cstruct), or a plain old functor? I don't see how your
infinitely adjustable set of classes makes the code any easier to read or
maintain. (Or it could be I need another cup of coffee...)
// TURN DAY DREAM ON.
IF C++ had a templated typedef, you could write it as a lambda statement.
template<class T>
typedef lambda_statement<T> CompareOperation;
struct C;
typedef containerType(C *, CompareOperation);
containerType container(CompareOperation(free1->*(&C::member1) >
free2->*(&C::member1)
&& ....
) );
But without that typedef, (and some other hand waving) writing the lambda
typedef operation would be grounds for cruel and unusual punishment.
// TURN DAY DREAM OFF.
-gary-
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk