David Abrahams wrote:
Careful; vector iterators are not neccessarily pointers.
Hm yes, that's true. But does this matter? I have a vector of some type, and a vector of pointers to some type. I don't even deal with iterators when working on the pointer-vector.
struct indirect_less { template <class It> bool operator()(It i1, It i2) const { typedef typename std::iterator_traits<It>::value_type value_type; return std::less
()(i1,i2); } }; sort(ptrcoll.begin(), ptrcoll.end, indirect_less());
Ah I see. But what, if I want to abstract from the predicate? I want to
create a class which is as generic as possible, so I don't have to
rewrite it for each and every possible predicate.
What if I want to pass the predicate to the constructor of this
template. For one, passing a pointer to a function returning bool and
taking on argument must be possible, and also passing a function object,
maybe of type std::unary_function.
template<typename It>
class indirect
{
const std::unary_function