Make some special member functions of promise and packaged_task defaulted#3315
Conversation
strega-nil-ms
left a comment
There was a problem hiding this comment.
This is great! Thanks @frederick-vs-ja
| _Promise(_Associated_state<_Ty>* _State_ptr) noexcept : _State(_State_ptr, false), _Future_retrieved(false) {} | ||
|
|
||
| _Promise(_Promise&& _Other) : _State(_STD move(_Other._State)), _Future_retrieved(_Other._Future_retrieved) {} | ||
| _Promise(_Promise&&) = default; |
There was a problem hiding this comment.
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>)
There was a problem hiding this comment.
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.)
| _Promise(_Associated_state<_Ty>* _State_ptr) noexcept : _State(_State_ptr, false), _Future_retrieved(false) {} | ||
|
|
||
| _Promise(_Promise&& _Other) : _State(_STD move(_Other._State)), _Future_retrieved(_Other._Future_retrieved) {} | ||
| _Promise(_Promise&&) = default; |
There was a problem hiding this comment.
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.)
| packaged_task() noexcept : _MyPromise(0) {} | ||
| packaged_task() = default; |
There was a problem hiding this comment.
No change requested: Wow, a 0-as-null-pointer was still lurking in the codebase! Nice catch!
|
I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. |
|
Thanks for these careful improvements! 😸 ✅ 🎉 |
Also update references to working draft to WG21-N4928 in
<future>.This is a follow-up change of #3284, and partially addresses #3278.