When adding a user defined default virtual destructor to a class like this..
class Foo
{
public:
Foo();
virtual ~Foo() = default;
};
.. It has the side effects of preventing auto generation of move constructors. Also auto generation of copy constructors is deprecated. A recommended way is to user define all constructors like this..
class Foo
{
public:
Foo();
virtual ~Foo() = default;
Foo(const Foo& /* other */) = default;
Foo&operator=(const Foo& /* other */) = default;
Foo(Foo&& /* other */) = default;
Foo&operator=(Foo&& /* other */) = default;
};
However, this is super verbose and unreadable. Are there any other solutions to this?
clone()
method instead. – Haematoxylin= delete
rather than= default
) - just to be clear about what the class is providing. (Arguably if you delete the "copy" functions, you don't need to mention the "move" functions.) – Ruffi