Boost logo

Boost :

From: Bo Persson (bop_at_[hidden])
Date: 2007-05-05 06:17:51


Jonathan Franklin wrote:
:: On 5/4/07, David Abrahams <dave_at_[hidden]> wrote:
:::
:::
::: For example, GCC has a
::: warning about a derived class whose base doesn't have a virtual
::: dtor. It's actually *impossible* (not just inefficient or
::: convoluted) to implement is_polymorphic without generating that
::: warning.
::
::
:: Interesting. I'm obviously flaunting my ignorance, but I didn't
:: realize
:: that inheriting from a class sans virtual dtor was ever a Good
:: Thing. I'll have to read up on the issues WRT is_polymorphic.
::

Here's an example from the standard library:

        template<class _Ty>
        struct plus
                : public binary_function<_Ty, _Ty, _Ty>
        { // functor for operator+
        _Ty operator()(const _Ty& _Left, const _Ty& _Right) const
                { // apply operator+ to operands
                return (_Left + _Right);
                }
        };

Neither plus nor binary_function has any virtual destructor, but they are
still useful.

You will not use them polymorphically though.

Bo Persson


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk