class EE::NonCopyable

Overview

Utility class that makes any derived class non-copyable. More…

#include <noncopyable.hpp>

class NonCopyable {
};

Detailed Documentation

Utility class that makes any derived class non-copyable.

This class makes its instances non-copyable, by explicitely disabling its copy constructor and its assignment operator. To create a non-copyable class, simply inherit from EE::NonCopyable. The type of inheritance (public or private) doesn’t matter, the copy constructor and assignment operator are declared private in EE::NonCopyable so they will end up being inaccessible in both cases. Thus you can use a shorter syntax for inheriting from it (see below). Usage example:

class MyNonCopyableClass : EE::NonCopyable
{

};

Deciding whether the instances of a class can be copied or not is a very important design choice. You are strongly encouraged to think about it before writing a class, and to use EE::NonCopyable when necessary to prevent many potential future errors when using it. This is also a very important indication to users of your class.