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

Make certain optional<T> operations trivial if they are for T #37

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from

Conversation

z33ky
Copy link

@z33ky z33ky commented Oct 24, 2017

See trac-issue.

daniel-j-h and others added 9 commits May 14, 2017 16:31
Enable tests that doesn't requires rv-ref.
Use BOOST_MAY_ALIAS from Boost.Config
optional<T>'s copy- and move-constructor, as well as its destructor are
made trivial, if they are for T.
Without defaultable constructors, only the trivial destructor is
implemented.
@akrzemi1
Copy link
Member

Yes. This will be a useful addition. I just need some time to implement it.

@z33ky
Copy link
Author

z33ky commented Oct 24, 2017 via email

@akrzemi1
Copy link
Member

Ooops, sorry. Somehow I only saw the test file. Let me review and test it.

@z33ky
Copy link
Author

z33ky commented Oct 24, 2017 via email

@akrzemi1
Copy link
Member

The alternative, which I had in mind would only specialize for trivial Ts. This is enough for most cases.

@akrzemi1
Copy link
Member

I can see how making optional<T> trivially_copyable fo trivial Ts can help, and I intend to support it. But I fail to see how making it only has_trivial_move_constructor can help anyone in anything. Could you give me an example of where this would be useful?

@z33ky
Copy link
Author

z33ky commented Oct 24, 2017 via email

@akrzemi1
Copy link
Member

For resource-managing classes move constructors are not trivial because you have to zero out the source object. If a class really has a trivial move constructor (it manages no resources), what would be the purpose for making it move-constructible but not copy-constructible? Have you ever seen one like that?

Or, to put my concerns in another way, if I only implement a coarse grained feature: "if T is trivial, optional<T> is trivially-copyable", would you be missing anything in practice?

@z33ky
Copy link
Author

z33ky commented Oct 24, 2017 via email

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

Successfully merging this pull request may close these issues.

5 participants