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

<future>: Divorce packaged_task from function #5009

Open
frederick-vs-ja opened this issue Oct 12, 2024 · 0 comments
Open

<future>: Divorce packaged_task from function #5009

frederick-vs-ja opened this issue Oct 12, 2024 · 0 comments
Labels
bug Something isn't working vNext Breaks binary compatibility

Comments

@frederick-vs-ja
Copy link
Contributor

Currently, the internal state class _Packaged_state used by packaged_task stores a function.

STL/stl/inc/future

Lines 481 to 486 in 37120ed

template <class _Ret, class... _ArgTypes>
class _Packaged_state<_Ret(_ArgTypes...)> : public _Associated_state<typename _P_arg_type<_Ret>::type> {
public:
using _Mybase = _Associated_state<typename _P_arg_type<_Ret>::type>;
using _Mydel = typename _Mybase::_Mydel;
using _Function_type = function<_Ret(_ArgTypes...)>; // TRANSITION, ABI, should not use std::function

STL/stl/inc/future

Lines 550 to 551 in 37120ed

private:
_Function_type _Fn;

However, function requires the stored target object to be copy constructible while packaged_task doesn't, which rendered our implementation strategy non-conforming (reject-valid) for a long while, see #321.

#4946 partially fixed the non-conformance. However, the fix was imperfect:

  • it introduced handling for move-only functors which function isn't supposed to support,
  • it was broken when one specializes function for program-defined types, although I don't think anyone should do this, and
  • when the functor's copy constructor is eligible but ill-formed, there's still hard error from it, which isn't supposed to happen for packaged_task.

In vNext where ABI breakage is available, we need to change the internal storage type. It seems that the implementation details of that type can be shared with move_only_function, but it doesn't seem possible to directly use move_only_function because move_only_function is only available since C++23.

vNext note: Resolving this issue will require breaking binary compatibility. We won't be able to accept pull requests for this issue until the vNext branch is available. See #169 for more information.

@CaseyCarter CaseyCarter added bug Something isn't working vNext Breaks binary compatibility labels Oct 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working vNext Breaks binary compatibility
Projects
None yet
Development

No branches or pull requests

2 participants