CppCoreGuidelines
CppCoreGuidelines copied to clipboard
Never delete a move constructor or move assignment operator
As quoted from @jwakely in https://github.com/microsoft/GSL/pull/842#issuecomment-673403244
Never delete a move constructor or move assignment operator. If you want moving to be equivalent to copying then do not write move ctor/assignment, and ensure there is a user-declared copy ctor or copy assignment operator or both (or a user-declared destructor) N.B. user-declared not user-provided, which means not_null(const not_null&) = default; is fine.
A counterexample is ClonableBase from C.21: If you define or =delete any copy, move, or destructor function, define or =delete them all but I think there could be a useful guideline here.
Yes, an absolute statement like "never" is never correct :-)
Maybe "never delete it unless you want to prevent moving and copying".
Editors call: @cubbimew please create a new guideline along these lines. Thanks!
So, it is important when we have a template member of a class and depending on who it is a move constructor or move assignment operator will be generated from that. Are there other cases where we shouldn't declare them?