
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. Example: Now we have template<typename SequenceT, typename PredicateT> void trim_if(SequenceT Seq, PredicateT Pred); and template<typename SequenceT> void trim(SequenceT Seq) { trim_if(Seq, is_space()); } I can change the second one to something like this: trim_if(Seq, boost::ref(is_space())); So it will go without copy penalty. Is this reasonable enough? Regards, Pavol