On 24 March 2017 at 11:32, Michał Kowalczyk <
m...@ekk.pl> wrote:
> Hi,
> In our team, we have a discussion about using override with virtual
> destructors.
> We found no information in the standard that it is even allowed but most
> compilers support it.
The standard does allow it, since virt-specifiers can be used with a
virtual function declaration,
and there's no special restriction that would prevent using them with
a destructor.
> We see that Google in its coding guidelines encourages using override with
> destructors:
> "Explicitly annotate overrides of virtual functions or virtual destructors
> with an override or (less frequently) final specifier."
> source:
https://google.github.io/styleguide/cppguide.html
>
> On the other hand C++ Core Guidelines says:
> "If a base class destructor is declared virtual, derived class destructors
> should neither be declared virtual nor override."
> src:
>
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md
>
> Did anyone find any superior answer for using override with destructors?
The benefit of using override with a destructor is that it also
ensures that the destructor is virtual.
Some people believe that that is unnecessary boiler-plate, and yet
others believe that if the base
class destructor is changed from virtual to non-virtual, it's harmful
to need to adjust derived
class destructors.
In other words, there is no superior answer that works for every use case.