Image Component Library (ICL)
|
Class interface for un-copyable classes. More...
#include <Uncopyable.h>
Protected Member Functions | |
Uncopyable () | |
Empty base constructor. | |
Private Member Functions | |
Uncopyable (const Uncopyable &other) | |
forbidden copy constructor | |
Uncopyable & | operator= (const Uncopyable &other) |
forbidden assignment operator |
Class interface for un-copyable classes.
In some cases, classes might not be copied e.g. if the implementation of this would be very complex and it provides no benefits to copy an instance of a particular class.
To forbid, that instance of this class might be copied, you can either implement a private copy constructor and a private assignment operator, or you can inherit the Uncopyable class.
The following example demonstrates how you can protect a picture from being copied:
#include <ICLUtils/Uncopyable.h> class Picasso : public Uncopyable{ ... }; int main(){ Picasso guernica; Picasso copyOfGuernica = guernica; // not allowed Picasso anotherTryToCopyGuernica( guernica ); // also not allowed return 0; }
icl::utils::Uncopyable::Uncopyable | ( | ) | [inline, protected] |
Empty base constructor.
icl::utils::Uncopyable::Uncopyable | ( | const Uncopyable & | other | ) | [inline, private] |
forbidden copy constructor
Uncopyable& icl::utils::Uncopyable::operator= | ( | const Uncopyable & | other | ) | [inline, private] |
forbidden assignment operator