The rule that the compiler shouldn't synthesize move operations for a class that declares a destructor or a copy operation (i.e. copy constructor/assignment) makes sense. Afterall, by declaring these operations, the class admits that it needs to do some custom bookkeeping.
However, this reasoning does not apply when the class defines the destructor or a copy operation as =default
? Shouldn't then this case be an exception from the rule?
EDIT: One reason I might want to define the destructor as =default
, but not the other special operations, is when I need a virtual destructor for the base class, so I am forced to define one to make it virtual.
Aucun commentaire:
Enregistrer un commentaire