Image Component Library (ICL)
|
Utility class for class instances that are created brand new on copy. More...
#include <UncopiedInstance.h>
Public Member Functions | |
UncopiedInstance (const T &t) | |
copy from parent constructor More... | |
UncopiedInstance () | |
default constructor calls T() More... | |
UncopiedInstance (const UncopiedInstance &other) | |
default copy constructor calls T() More... | |
UncopiedInstance & | operator= (const UncopiedInstance &other) |
assignment operator (does NOT call T::operator=(other)) More... | |
Utility class for class instances that are created brand new on copy.
Consider the following problem: You have a class with some mutex'ed interface
As the mutex class is an instance of the Uncopyable interfaces, it cannot be copied. Furthermore, all classes X that have a member of type Mutex are Uncopyable too, unless, A special copy constructor and assignment operator for X is defined. This can be bypassed using the UncopiedInstance interface.
Due to template based inheritance, Uncopied instances can be used as their (templated) child instances. One major drawback is, that the wrapped T instance (wrapped by inheritance) is always constructed using the ()-empty constructor.
The Camera class from above can simply use the default copy constructor and assignment operator if we use an UncopiedInstance<Mutex> instead of the Mutex class itself.
|
inline |
copy from parent constructor
|
inline |
default constructor calls T()
|
inline |
default copy constructor calls T()
|
inline |
assignment operator (does NOT call T::operator=(other))