
From: Felipe Magno de Almeida <felipe.m.almeida@gmail.com>
On 8/31/05, Christopher Kohlhoff <chris@kohlhoff.com> wrote:
The overhead is not the virtual function call itself, but all the other stuff that gets generated by the compiler as soon as you add a virtual function to a class (e.g. vtable, RTTI etc).
Now I see. But.. Does it worth rewriting virtual mechanisms? I think that boost libraries rely a lot on compilers doing the right job and write code that, when possible, are elegant. I think it is a lot more readable with virtual functions. And it's not only with win_iocp_operation that this happens I think.
If this is only intended to be "overridden" via the function pointer in a few derived classes, I agree with you that avoiding virtual functions is confusing at best. (I jumped into the middle of the discussion and thought that unrelated functions might be passed as arguments.) I'd say that unless you know that using virtual functions causes problems, you shouldn't presume that they do. If users say the library is too big and this technique significantly affects the size, then it may be worth considering at that time. You might also consider whether the Strategy pattern applies here. -- Rob Stewart stewart@sig.com Software Engineer http://www.sig.com Susquehanna International Group, LLP using std::disclaimer;