Implementing normal algorithms using predicate versions

chris caj@cs.york.ac.uk
Sun Nov 28 16:15:00 GMT 2004


Paolo Carlini wrote:

> chris wrote:
>
>> I was intending on using something like (warning: away from C++ 
>> compiler, I haven't even compiled this code!)
>>
>> template<typename __T1, typename __T2>
>> struct __default_predicate {
>> bool
>> operator()(const __T1& __t1, const __T2& __t2) { return __t1<__t2;}
>> };
>
>
> Ah, yes, this - or slight variations - look good. Maybe we should 
> discuss a bit
> more the optimization thing and then, possibly, actually implement the 
> idea
> in v7... :)
>
While we are discussing optimisations, I wonder if a liberal spreading 
of "inline" might not be useful? I'm not so much thinking about inlining 
small functions just because they are small, I trust g++ to decide when 
to do that itself. I was more thinking that when we have "dispatching" 
functions for specialisations (such as these), we should either inline 
the dispatching function, or the functions which are dispatched to perhaps?

Personally, while it is the less obvious choice, I would probably inline 
the dispatching functions, as they should after inlining in theory 
compile away to nothing at all.

Chris



More information about the Libstdc++ mailing list