RFC: New C++ Attribute: final

Gabriel Dos Reis gdr@integrable-solutions.net
Mon Mar 1 15:02:00 GMT 2004


Jeff Sturm <jsturm@one-point.com> writes:

| If a base class declares a method 'virtual' in C++, can a derived class
| override the modifier, such that calls to the overridden method do
| not require vtable dispatch?

It depends on the compiler and how you organize your program.  Defunct
KCC was able to use type information from your program, do static
analyzis and optimize out vcalls.  But you can fool it, though, if
you're determined.  Note also that if you have a good linker, it can
determine most of the cases when a virtual function is not overriden
and optimize the vcall.

"final" is probably one of the most recurent keywords people want to
borrow from other programming languages and add to C++.  MS is recently
recycling it as "sealed".  The next recurent keyword probably is
"override".

-- Gaby



More information about the Gcc mailing list