![]() |
User Manual, Developers Guide and API Documentation |
![]() |
#include <NonCopyable.hpp>

Protected Member Functions | |
| NonCopyable () | |
| Avoid instantiation of NonCopyable object (useless). | |
| virtual | ~NonCopyable () |
| Avoid deletion of NonCopyable object (symmetric with c'tor). | |
Private Member Functions | |
| NonCopyable (const NonCopyable &) | |
| Private and not implemented to forbid copy construction. | |
| NonCopyable & | operator= (const NonCopyable &) |
| Private and not implemented to forbid assignment. | |
Some objects, particularly those which hold complex resources like files or network connections, have no sensible copy semantics. Sometimes there are possible copy semantics, but these would be of very limited usefulness and be very difficult to implement correctly. Sometimes you're implementing a class that doesn't need to be copied just yet and you don't want to take the time to write the appropriate functions. Deriving from NonCopyable will prevent the otherwise implicitly-generated functions (which don't have the proper semantics) from becoming a trap for other programmers.
The traditional way to deal with these is to declare a private copy constructor and copy assignment, and then document why this is done. But deriving from NonCopyable is simpler and clearer, and doesn't require additional documentation.
Definition at line 56 of file NonCopyable.hpp.
| wns::NonCopyable::NonCopyable | ( | ) | [inline, protected] |
Definition at line 62 of file NonCopyable.hpp.
| virtual wns::NonCopyable::~NonCopyable | ( | ) | [inline, protected, virtual] |
Definition at line 70 of file NonCopyable.hpp.
| wns::NonCopyable::NonCopyable | ( | const NonCopyable & | ) | [private] |
| NonCopyable& wns::NonCopyable::operator= | ( | const NonCopyable & | ) | [private] |
1.5.5