Boost logo

Boost :

From: Stefan Seefeld (seefeld_at_[hidden])
Date: 2008-05-03 16:38:57


Simonson, Lucanus J wrote:

> I clearly understand the reason why the destructor of polymorphic types
> should be declared virtual. I was trying to make an argument against
> polymorphism in general, because it produces much greater runtime
> overhead than most people seem to appreciate when used on simple types

Hmm, 'much greater runtime overhead' is quite strong. This needs to be
backed up for every particular case, to assess the real impact.
Otherwise any such concern is just premature optimization.

> that should be heavily inlined. In fact, I don't myself understand the

Even inlining itself can have (negative) impact on performance, as you
increase code size.

And, speaking of performance, there are sometimes good reasons not to
use exceptions (not even exception *specifiers*), since this involves
added synthesized code that incurs performance overhead.
So, whether that particular case of 'virtual' is worth all the trouble
is questionable.

> reason Emil has for not declaring the destructor virtual in this case.
> He said he didn't care about overhead, after all. I was simply pointing
> out that the overhead is greater than what Hartmut suggested. So great,
> in fact, that I prefer to avoid polymorphic programming style for that
> very reason.

Yes, understood.

Thanks,
                Stefan

-- 
       ...ich hab' noch einen Koffer in Berlin...

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk