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 some special member functions of promise and packaged_task defaulted #3315

Merged
merged 3 commits into from
Jan 12, 2023

Conversation

frederick-vs-ja
Copy link
Contributor

Also update references to working draft to WG21-N4928 in <future>.

This is a follow-up change of #3284, and partially addresses #3278.

@frederick-vs-ja frederick-vs-ja requested a review from a team as a code owner December 31, 2022 12:42
Copy link
Contributor

@strega-nil-ms strega-nil-ms left a comment

Choose a reason for hiding this comment

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

This is great! Thanks @frederick-vs-ja


_Promise(_Promise&& _Other) : _State(_STD move(_Other._State)), _Future_retrieved(_Other._Future_retrieved) {}
_Promise(_Promise&&) = default;
Copy link
Contributor

Choose a reason for hiding this comment

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

Note that this does not make _Promise<T> trivially moveable since _State_manager<T> is never trivially moveable (and therefore same for promise<T> and packaged_task<T>)

Copy link
Member

Choose a reason for hiding this comment

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

Thanks, I think that makes this ABI-safe. (This is very close to the dangerous condition that I encountered in tuple<>'s copy ctor, though.)

@strega-nil-ms strega-nil-ms added the enhancement Something can be improved label Jan 3, 2023

_Promise(_Promise&& _Other) : _State(_STD move(_Other._State)), _Future_retrieved(_Other._Future_retrieved) {}
_Promise(_Promise&&) = default;
Copy link
Member

Choose a reason for hiding this comment

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

Thanks, I think that makes this ABI-safe. (This is very close to the dangerous condition that I encountered in tuple<>'s copy ctor, though.)

Comment on lines -1319 to +1313
packaged_task() noexcept : _MyPromise(0) {}
packaged_task() = default;
Copy link
Member

Choose a reason for hiding this comment

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

No change requested: Wow, a 0-as-null-pointer was still lurking in the codebase! Nice catch!

@StephanTLavavej StephanTLavavej self-assigned this Jan 11, 2023
@StephanTLavavej
Copy link
Member

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@StephanTLavavej StephanTLavavej merged commit f5de9ad into microsoft:main Jan 12, 2023
@StephanTLavavej
Copy link
Member

Thanks for these careful improvements! 😸 ✅ 🎉

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

Successfully merging this pull request may close these issues.

3 participants