Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Remove virtual function specifiers where override is used #1458
Virtual function specifiers have always been implicitly inherited from their base classes. So the use of the virtual keyword in these cases has been redundant but was recommended in pre-modern C++ so that it was more easily distinguishable from non-virtual functions when reading derived class definitions. However since C++11, the override specifier has superseded this with compile time safety, and so explicitly writing both in a derived class is not required.
I propose that the virtual specifier is removed in any function declaration where both the override and virtual function specifiers are used.
The following command was used in the root directory to find and replace all instances where virtual and override specifiers were used.
There were 2 files which were affected, one was rai/lib/expected.hpp but as this is third party code it has been left as is.
This change has not checked whether there are places override should be used where it is currently not.
I'm unfamiliar with both these clang tools. It looks like there is clang-tidy --modernize-use-override:
Having something like that in the pipeline would definitely be beneficial