If class X is derived from class Y and class Y has any of:
- A user-declared copy constructor,
- A user-declared copy assignment operator,
- A user-declared destructor
- A user-declared move constructor,
- A user-declared move assignment operator,
Will a move constructor and move assignment operator be implicitly defaulted for class X providing it declares none of the above?
e.g.
struct Y
{
virtual ~Y() {}
// .... stuff
};
struct X : public Y
{
// ... stuff but no destructor,
// no copy/move assignment operator
// no copy/move constructor
// will X have a default move constructor / assignment operator?
};
I am currently using gcc, but I am mainly interested in what the correct behaviour should be (as opposed to whether or not a particular compiler is standards compliant)..
virtual ~Y() = default;rather than define the destructor yourself (although perhaps your compiler doesn't support it yet). - Luc Dantonvirtual ~Y() = default;will that trigger the compiler to implicitly default the move constructor / assignment operator? or would I need to explicitly default these operations? - mark