From: Tobias Schwinger (tschwinger_at_[hidden])
Date: 2006-05-02 14:46:15
Doug Gregor wrote:
> On May 2, 2006, at 1:01 PM, Neal Becker wrote:
>>David Abrahams wrote:
>>>Actually it's not a virtual call, it's a call through a function
>>>pointer. That's one less indirection.
>>Do you think a smart compiler might optimize this to a direct call?
> I have yet to see a compiler smart enough to optimize this indirection.
Say we use a functor class template adapter with a function pointer as non-type template parameter...
In case we pass it to function templates that treat functors uniformly (such as std algorithms), the compiler has (at least theoretically) a fair chance to make an absolute call or even to inline.
Boost.Function, however, implements distinct handling for function objects and function pointers. So, is there any chance for reducing the work at the call site with this technique?