From: Rob Stewart (stewart_at_[hidden])
Date: 2005-08-31 15:52:54
From: Felipe Magno de Almeida <felipe.m.almeida_at_[hidden]>
> On 8/31/05, Christopher Kohlhoff <chris_at_[hidden]> 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
-- Rob Stewart stewart_at_[hidden] Software Engineer http://www.sig.com Susquehanna International Group, LLP using std::disclaimer;
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk