My Project
 All Classes Namespaces Files Functions Typedefs Enumerations Enumerator Properties Macros
unity::util::NonCopyable_::NonCopyable Class Reference

Helper class to prevent a class from being copied. More...

#include <unity/util/NonCopyable.h>

Inheritance diagram for unity::util::NonCopyable_::NonCopyable:

Detailed Description

Helper class to prevent a class from being copied.

This class disables the copy constructor and assignment operator of a class to prevent it from being copied. This makes the fact that a class is not copyable immediately visible on reading the class definition, rather than having to read through the entire class to look for a copy constructor and assignment operator in the private section, or having to look for = delete; on the corresponding definitions.

To use the class, use private inheritance:

class MyClass : private unity::util::NonCopyable
{
public:
// MyClass cannot be copied now
// ...
};
Note
Do not use public or protected inheritance for this class. Private inheritance prevents accidental polymorphism, such as
void some_method(NonCopyable& param); // Bad, permits unrelated classes to be passed

The documentation for this class was generated from the following file: