From: David Abrahams (david.abrahams_at_[hidden])
Date: 2001-11-26 09:18:44
----- Original Message -----
From: "Emily Winch" <emily_at_[hidden]>
> For there to be any prospect of writing code that is generic with respect
> predicates like this, you'd _have_ to detect all class relationships in
> same way, or at least write a bunch of adaptors to make that possible.
> I'm not convinced that this looks sensible though:
> whatever< smaller<T>, bigger<U> >::value
> rather than
> is_bigger< T, U >::value
> And if we assume that any predicate over N types must be expressed in
> of N names, we are forcing the writer of the aforementioned generic code
> take an extra N template parameters to represent the predicate, rather
> 1. That would make the code REALLY ugly, even if we only consider N=2.
> (since I can't think of an example with N > 2)
That's a good point.
> I thought of a practical use of a two-parameter type predicate passed as a
> template template parameter. If you sort a tuple by the size of the
> so the biggest ones go first, you might make it smaller (less padding
> required). Clearly this would be neatly achieved by passing is_bigger as a
> predicate to a sorting algorithm.
Yes, believe it or not I used a compile-time insertion sort with a binary
predicate in my last job!
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk