I like to compile my code using -Wsuggest-final-typesand -Wsuggest-final-methodsto get warnings about the possibilities of using a keyword finalso that the compiler can optimize more aggressively.
Sometimes, however, the sentences are incorrect - for example, I have a class Basewith a destructor virtual ~Base()that is used polymorphically in another project, and gcc offers me so that I Basecan mark it as final.
Is there a way to “purely” tell the compiler that it is Baseused polymorphically and should not be marked as final?
The only way I can think of is to use directives #pragma, but I find this makes the code cluttered and hard to read.
Ideally, I am looking for a keyword or attribute non-finalthat can be added / added to a class / method declaration.
source
share