Jump to content

How to Ensure a Class is not Copyable or Movable -- Sandor Dargo


Horizon

Recommended Posts

Dargo-classisnotcopyable.pngThe 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.

View the full article

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...