From 070d3e7d39f654edb355f1908851eb9fe9a425d7 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Fri, 17 Jul 2015 18:19:52 -0600 Subject: [PATCH] Add a note about the rule of 0 --- 03-Style.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/03-Style.md b/03-Style.md index 07ae0fb..e39ae1c 100644 --- a/03-Style.md +++ b/03-Style.md @@ -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. +