At this point, writing the copy constructor and assignment operator pair is well-defined; a quick search will lead you to plenty of hits on how to properly code these.
Now that the move constructor has entered the mix, is there a new "best" way?
Preferably, they'll just be = default;
, since the member types should be of resource managing types that hide the move details from you, like std::unique_ptr
. Only the implementors of those "low level" types should bother with dealing with that.
Remember that you only need to bother with move semantics if you're holding an external (to your object) resource. It's completely useless for "flat" types.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With