On Sun, Jun 12, 2016 at 10:15 AM, Vinícius dos Santos Oliveira
<
vini.i...@gmail.com> wrote:
> I think it's important to avoid user mistakes.
Here I'm going to disagree. The destructors in question are clearly
marked non-virtual. I don't think its the programmer's job to mitigate
misuse arising from users who do not inspect the classes from which
they are deriving. The spectrum of such possible mistakes is
potentially infinite.
Neither std::pair nor std::vector have virtual destructors, or attempt
to mitigate the consequence of slicing a derived class with a
non-trivial destructor.
If you feel that such mitigation is more important to your users than
say, avoiding the cost of giving a class an unnecessary virtual table,
then of course you should take measures to protect those users. But I
hardly think that this should be a practice adopted generally, for the
reason that it goes against "pay for what you use" which is one of the
primary advantages of using C++ over other languages that try to
"help" the user by doing unnecessary things (for example, automatic
zero-initialization of data members in Java objects).