Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UNCOPYABLE vs. uncopyable #9

Open
rolandreichweinbmw opened this issue Oct 29, 2024 · 1 comment
Open

UNCOPYABLE vs. uncopyable #9

rolandreichweinbmw opened this issue Oct 29, 2024 · 1 comment

Comments

@rolandreichweinbmw
Copy link
Contributor

As I understand, the Macro UNCOPYABLE is included in estd's uncopyable.h for historical reasons?

Instead, the base class estd::uncopyable can be used instead consequently, since using C++ means is mostly better than preprocessor means.

@vladyslavmarkovaccenture
Copy link
Contributor

As I understand, the Macro UNCOPYABLE is included in estd's uncopyable.h for historical reasons?

Exactly. The UNCOPYABLE macro will be removed in the future as it is deprecated.

Instead, the base class estd::uncopyable can be used instead consequently, since using C++ means is mostly better than preprocessor means.

The current preferred way to make a class non-copyable is to declare the copy constructor and copy assignment operator as = deleted under the public: access specifier (see C++ core guidelines: C.81).

A less preferred, more Boost-like approach is private inheritance from estd::uncopyable, as it:

  • Clutters the class hierarchy
  • Creates inconsistency in class interface definitions when applying the Rule of Five

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants