NonCopyable Class Reference

Inheritance diagram for NonCopyable:

ElementListT SectionListT Manager ObjPool SharedPtr_FatBase SharedPtr_ThinBase SharedObj CriticalSection Locker List of all members.

Detailed Description

Non-Copyable interface.

Some classes should not support copying due to design purposes. A common practice is to declare copy constructor and assignment operator in the private section and not to define them.

  class X {
  public:
    // ...

  private: // copying not allowed
    X& operator=(const X&); // (!) not defined
    X(const X&);            // (!) not defined
  };

This practice is good, but too verbose. You should add these private declarations for each appropriated class. Moreover, it is not so clear for users. A better practice is to derive your class from the NonCopyable interface.

  // default copying not allowed
  class Y: private omni::NonCopyable {
  public:
    // ...
  };

Class NonCopyable is used to protect derived classes from default copying (copy constructor and assignment operator which compiler generates by default). It is recommended to use private derivation.

Note that NonCopyable is not strict copying protection. Derived classes may define their own copy constructor and/or assignment operator.

Protected Member Functions


Constructor & Destructor Documentation

NonCopyable (  )  [inline, protected]

Trivial constructor.

~NonCopyable (  )  [inline, protected]

Trivial destructor.


Generated on Wed Jun 6 17:27:47 2007 for OMNI by  doxygen 1.5.2