Add a note about the rule of 0

This commit is contained in:
Jason Turner
2015-07-17 18:19:52 -06:00
parent 34bf08ef45
commit 070d3e7d39

View File

@@ -305,3 +305,12 @@ They can help you stick to [DRY principles](http://en.wikipedia.org/wiki/Don%27t
They should be preferred to macros, because macros do not honor namespaces, etc. They should be preferred to macros, because macros do not honor namespaces, etc.
## Use Operator Overloads Judiciously ## Use Operator Overloads Judiciously
## Consider the Rule of Zero
The Rule of Zero states that you do not provide any of the functions that the compiler can provide (copy constructor, assignment operator, move constructor, destructor, move constructor) unless the class you are constructing does some novel form of ownership.
The goal is to let the compiler provide optimal versions that are automatically maintained when more member variables are added.
The [original article](http://flamingdangerzone.com/cxx11/rule-of-zero/) provides the background, while a [follow up article](https://turingtester.wordpress.com/2015/06/27/cs-rule-of-zero/) explains techniques for implementing nearly 100% of the time.