mirror of
https://github.com/cpp-best-practices/cppbestpractices.git
synced 2025-12-17 03:04:36 +03:00
Add a note about the rule of 0
This commit is contained in:
@@ -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.
|
||||
|
||||
## 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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user