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

Add uncopyable.h, class uncopyable #985

Conversation

rolandreichweinbmw
Copy link

No description provided.

@rolandreichweinbmw
Copy link
Author

I don't see a way to add a unit test for this feature. It's a convenience feature which being applied incorrectly would not compile.

@rolandreichweinbmw
Copy link
Author

If you prefer a unit test including a dummy use of this class (non-functional feature), I can add it.

uncopyable& operator=(uncopyable const&) = delete;

protected:
uncopyable() = default;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've see comments online that Scott Meyers also adds the destructor in his 'Effective C++' book.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I.e. a non-virtual public "=default" destructor?

Is there a reasoning behind it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like it is intended to make the destructor protected, rather than default public.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the destructor.

@jwellbelove jwellbelove changed the base branch from master to pull-request/#985-Add-uncopyable.h-class-uncopyable December 10, 2024 13:10
@jwellbelove
Copy link
Contributor

I have sometimes added a commented out unit test that contains 'uncompilable' code, with a surrounding comment that the test should fail to compile if uncommented.
It can be useful if you want to check that the disabled functionality is still disabled after a code change.

@jwellbelove
Copy link
Contributor

I also sometimes do this for static_assert checks.

@rolandreichweinbmw
Copy link
Author

I just added the destructor as discussed, and unit tests, including disabled code that intentionally wouldn't compile.

@jwellbelove jwellbelove merged commit 0ecab77 into ETLCPP:pull-request/#985-Add-uncopyable.h-class-uncopyable Dec 10, 2024
63 checks passed
jwellbelove added a commit that referenced this pull request Dec 12, 2024
jwellbelove pushed a commit that referenced this pull request Dec 19, 2024
* Add uncopyable.h, class uncopyable

* Added destructor and unit tests for etl::uncopyable
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

Successfully merging this pull request may close these issues.

2 participants