vendredi 27 novembre 2015

Does default virtual destructor prevent compiler generated move operations?

Inspired by this post Why destructor disabling the generation of implicit move functions I was wondering if the same is true for the default virtual destructor, e.g.

class WidgetBase // base class of all widgets
{
public:
    virtual ~WidgetBase() = default;
    // ...
};

As the class is intended to by a base class of a widget hierarchy I have to define it's destructor virtual to avoid memory leaks and undefined behavior when working with base class pointers. On the other hand I don't want to prevent the compiler from automatically generating move operations.

Does default virtual destructor prevent compiler generated move operations ?

Aucun commentaire:

Enregistrer un commentaire