Monday, December 11, 2017

C++14: The Rule of Three/Five/Zero

Rule of Three – If a class requires either user-defined  destructor, copy constructor, or copy assignment, it usually requires all three.

Rule of Five – If Rule of Three is in action, and also move semantics are needed then the move constructor and move assignment operator are also needed.

Rule of Zero – “Classes that have custom destructors, copy/move constructors or copy/move assignment operators should deal exclusively with ownership.” – R. Martinho Fernandes

References:

No comments:

Post a Comment