RFC: New C++ Attribute: final

Joe Buck Joe.Buck@synopsys.COM
Mon Mar 1 20:18:00 GMT 2004


On Mon, Mar 01, 2004 at 08:48:08PM +0100, Gabriel Dos Reis wrote:
> There is no doubt that people will construct examples where they
> think they need final for C++.

Such code already exists in large amounts, but does not use "final"
because there is no such keyword.

To work around the lack of "final", one of two approaches is taken:

a) favor speed.  In this case, non-virtual methods are used, and it is
   forbidden (by style rules for the project) to override these methods
   or to do derivation in such a way as to break the nonvirtual method.

b) favor safety and extensibility, sacrifice performance.  In this case,
   calls remain virtual although there is no override anywhere.

In case a), addition of "final" would increase robustness, by allowing
the compiler to detect design rule violations.

In case b), addition of "final" would improve performance.



More information about the Gcc mailing list