There are reasons why you might want to use public inheritance that have nothing to do with run-time polymorphism.
There are reasons why you might want to use public inheritance that have nothing to do with run-time polymorphism.
It seems like, if you're not providing a virtual destructor, you force users into delegation rather than inheritance, and that will catch some % of developers who aren't on the ball. They'll have leaks...
As far as i know (old info) there's no such thing as a "final" class, so anybody can inherit even if you don't want them to.
Anyone can technically publicly inherit from a value class, but if they do it's absolutely their fault :)
You have the `final` specifier since C++11 to state a class cannot be inherited from, but this notion of "You really shouldn't inherit from this class." has been around since classical object orientation has, C++ just couldn't express it as a language.
So if your class currently isn't being inherited from, make your public dtor nonvirtual. If and when it needs to be a base class, then the author can modify your class to have a virtual dtor, or use composition (which is often the superior alternative). If source code is not available, then composition it is. I would advise against making it virtual "just in case", that's premature pessimisation.
You mean per-object vtable pointer? Or per-type vtable?
Slicing isn't even necessarily harmful either... but I'm not sure what you had in mind.