Title
The Mandates for std::packaged_task's constructor from a callable entity should consider decaying
Status
wp
Section
[futures.task.members]
Submitter
Jiang An

Created on 2024-09-18.00:00:00 last changed 3 weeks ago

Messages

Date: 2024-11-28.21:40:31

Proposed resolution:

This wording is relative to N4988.

  1. Modify [futures.task.members] as indicated:

    template<class F>
      explicit packaged_task(F&& f);

    -2- Constraints: remove_cvref_t<F> is not the same type as packaged_task<R(ArgTypes...)>.

    -3- Mandates: is_invocable_r_v<R, Fdecay_t<F>&, ArgTypes...> is `true`.

    -4- Preconditions: Invoking a copy of `f` behaves the same as invoking `f`.

    -5- Effects: Constructs a new `packaged_task` object with a stored task of type decay_t<F> and a shared state . Initializes and initializes the object's stored task with std::forward<F>(f).

Date: 2024-11-28.21:40:31

[ Wrocław 2024-11-23; Status changed: Voting → WP. ]

Date: 2024-10-15.00:00:00

[ 2024-10-09; LWG telecon: Move to Ready ]

Date: 2024-10-15.00:00:00

[ 2024-10-02; LWG telecon ]

Clarify that "of type decay_t<F>" is supposed to be specifying the type of the stored task.

Date: 2024-10-15.00:00:00

[ 2024-10-02; Jonathan provides improved wording ]

Drop preconditions as suggested on reflector.

Date: 2024-10-15.00:00:00

[ 2024-10-02; Reflector poll ]

Set priority to 3 after reflector poll.

"Fix preconditions, `f` doesn't need to be invocable, we only invoke the copy."

This wording is relative to N4988.

  1. Modify [futures.task.members] as indicated:

    -3- Mandates: is_invocable_r_v<R, Fdecay_t<F>&, ArgTypes...> is `true`.

    [...]

    -5- Effects: Constructs a new `packaged_task` object with a shared state and initializes the object's stored task of type decay_t<F> with std::forward<F>(f).

Date: 2024-09-18.00:00:00

Currently, [futures.task.members]/3 states:

Mandates: is_invocable_r_v<R, F&, ArgTypes...> is `true`.
where F& can be a reference to a cv-qualified function object type.

However, in mainstream implementations (libc++, libstdc++, and MSVC STL), the stored task object always has a cv-unqualified type, and thus the cv-qualification is unrecognizable in `operator()`.

Since [func.wrap.func.con] uses a decayed type, perhaps we should also so specify for `std::packaged_task`.

History
Date User Action Args
2024-11-28 21:40:31adminsetmessages: + msg14496
2024-11-28 21:40:31adminsetstatus: voting -> wp
2024-11-19 16:09:07adminsetstatus: ready -> voting
2024-10-09 16:54:43adminsetmessages: + msg14435
2024-10-09 16:54:43adminsetstatus: new -> ready
2024-10-02 16:35:20adminsetmessages: + msg14411
2024-10-02 12:45:24adminsetmessages: + msg14408
2024-10-02 12:43:09adminsetmessages: + msg14406
2024-09-18 19:52:10adminsetmessages: + msg14371
2024-09-18 00:00:00admincreate