How to Ensure a Class is not Copyable or Movable -- Sandor Dargo
The topic of this post is to show different ways to ensure that a class is either non-moveable or non-copyable.
How to Ensure a Class is not Copyable or Movable
by Sandor Dargo
From the article:
If we follow the classification proposed by Sebastian Theophil, we can talk about 4 different class types:
- value classes
- container classes
- resource classes
- singleton classes
While the first two should be regular classes offering both copy and move semantics, the latter two are different. One shouldn’t be able to copy resources and singletons probably shouldn’t be moveable.
It’s up to us to ensure that a class we create implements the right special member functions (SMFs from now on). And the Hinnant table is here to guide us.