Closed miemoe closed 3 weeks ago
Interesting observation. If I am understanding it correctly, the point is that a class could be said to be following the "rule of zero" even if has constructors that are not the copy/move constructors [Rule of zero example in cppreference].
The potentially confusing issue I see in that case is that then, of course, the class would have at least one special operation defined (a constructor) rather than zero (even if it is indeed not a copy or move constructor).
Personally, I think the titles in C.20 and C.21 ("If you can avoid defining default operations, do" and "If you define or =delete any copy, move, or destructor function, define or =delete them all") help better avoiding this ambiguity, and the "rules of" help as mnemonics.
Having said that, I agree that a second example in C.20 with a constructor that is not one of copy or move, with or without parameters could help re-emphasizing that they do not imply C.21 (noting that this is already covered by C.21's title).
Editors call: Thanks! We'll add a constructor to C.20.
The "default operations" (btw. a term not used in the ISO standard, but special member functions?) include the default constructor.
The C.20 example and wording does not talk-about/show a "user defined default constructor" or "user defined constructors" explicitly.
To my understanding the "rule of zero" does not refer to the declaration of constructors, but only to the remaining 5 default operations:
Please have a look at the explanation of "Rule of zero" in https://en.cppreference.com/w/cpp/language/rule_of_three
Looking at C.21 (rule of five): there is explicitly no mentioning of any constructors in the rule.
So, it looks as if C.20 is not the opposite of C.21.
How about extending the example in C.20 with a constructor (user defined with or without parameters) or have a second example with declared constructors?