Protected Member Functions | List of all members
cpp3ds::NonCopyable Class Reference

Utility class that makes any derived class non-copyable. More...

#include <NonCopyable.hpp>

Inheritance diagram for cpp3ds::NonCopyable:
cpp3ds::Context cpp3ds::FileInputStream cpp3ds::Ftp cpp3ds::Http cpp3ds::InputSoundFile cpp3ds::Lock cpp3ds::Mutex cpp3ds::OutputSoundFile cpp3ds::RenderTarget cpp3ds::Shader cpp3ds::Socket cpp3ds::Thread cpp3ds::ThreadLocal

Protected Member Functions

 NonCopyable ()
 Default constructor. More...
 

Detailed Description

Utility class that makes any derived class non-copyable.

This class makes its instances non-copyable, by explicitely disabling its copy constructor and its assignment operator.

To create a non-copyable class, simply inherit from cpp3ds::NonCopyable.

The type of inheritance (public or private) doesn't matter, the copy constructor and assignment operator are declared private in cpp3ds::NonCopyable so they will end up being inaccessible in both cases. Thus you can use a shorter syntax for inheriting from it (see below).

Usage example:

class MyNonCopyableClass : cpp3ds::NonCopyable
{
...
};

Deciding whether the instances of a class can be copied or not is a very important design choice. You are strongly encouraged to think about it before writing a class, and to use cpp3ds::NonCopyable when necessary to prevent many potential future errors when using it. This is also a very important indication to users of your class.

Definition at line 35 of file NonCopyable.hpp.

Constructor & Destructor Documentation

cpp3ds::NonCopyable::NonCopyable ( )
inlineprotected

Default constructor.

Because this class has a copy constructor, the compiler will not automatically generate the default constructor. That's why we must define it explicitely.

Definition at line 47 of file NonCopyable.hpp.


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