Rule of zero in a real code base

In practice, the cases where you have to write your own copy/move-constructors and copy/move-assignments should be very few. If you create a class in your application code base which requires these to be custom written, these parts should probably be moved to some library in your code base.

Writing your classes so that they do not require any explicitly written copy-constructor, copy-assignment, move-constructor, move-assignment, or destructor is often referred to as the rule of zero. This means that if a class in the application code base is required to have any of these function written explicitly, that piece of code would probably be better off in the library part of your code base.

Later on in this chapter ...

Get C++ High Performance now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.