From: Pavol Droba (droba_at_[hidden])
Date: 2006-07-21 09:19:32
Sebastian Redl wrote:
> Pavol Droba wrote:
>> Now my comments to your patches:
>> 1.) const Predicate& Pred
>> Although this change can bring a performance benefits, it has one big
>> drawback. You cannot pass an ordinary C function as predicate.
>> At least not in VC++ 7.1
> Would it be possible to use the argument_traits library to determine the
> most efficient way of passing the argument? Or would that destroy the
> deduction of template arguments?
Do you mean call_traits? As far as I know, they don't have special
support for function pointer. In addition, they cannot be
directly used on function templates. Any such a facility needs to
know the type of the argument beforehand, so it can be transformed
into result type. This is not a case in function templates.
The only generic way I'm aware of is the usage of enable_if. But this
would make the interface quite messy. Especialy when there is quite
a lot of functions which are affected.
Anyway, I think, I know a reasonable compromise. I will leave function
definitions as they are now, but internaly I will call them with boost::ref.
Now we have
template<typename SequenceT, typename PredicateT>
void trim_if(SequenceT Seq, PredicateT Pred);
void trim(SequenceT Seq)
I can change the second one to something like this:
So it will go without copy penalty.
Is this reasonable enough?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk