This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of WP status.
std::packaged_task
's constructor from a callable entity should consider decayingSection: 32.10.10.2 [futures.task.members] Status: WP Submitter: Jiang An Opened: 2024-09-18 Last modified: 2024-11-28
Priority: 3
View all other issues in [futures.task.members].
View all issues with WP status.
Discussion:
Currently, 32.10.10.2 [futures.task.members]/3 states:
Mandates:whereis_invocable_r_v<R, F&, ArgTypes...>
istrue
.
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 22.10.17.3.2 [func.wrap.func.con] uses a decayed type,
perhaps we should also so specify for std::packaged_task
.
[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."
Previous resolution [SUPERSEDED]:
This wording is relative to N4988.
Modify 32.10.10.2 [futures.task.members] as indicated:
-3- Mandates:
[...]is_invocable_r_v<R,
isFdecay_t<F>&, ArgTypes...>true
.-5- Effects: Constructs a new
packaged_task
object with a shared state and initializes the object's stored task of typedecay_t<F>
withstd::forward<F>(f)
.
[2024-10-02; Jonathan provides improved wording]
Drop preconditions as suggested on reflector.
[2024-10-02; LWG telecon]
Clarify that "of type decay_t<F>
"
is supposed to be specifying the type of the stored task.
[2024-10-09; LWG telecon: Move to Ready]
[Wrocław 2024-11-23; Status changed: Voting → WP.]
Proposed resolution:
This wording is relative to N4988.
Modify 32.10.10.2 [futures.task.members] as indicated:
template<class F> explicit packaged_task(F&& f);
-2- Constraints:
remove_cvref_t<F>
is not the same type aspackaged_task<R(ArgTypes...)>
.-3- Mandates:
is_invocable_r_v<R,
isFdecay_t<F>&, ArgTypes...>true
.
-4- Preconditions: Invoking a copy off
behaves the same as invokingf
.-5- Effects: Constructs a new
packaged_task
object with a stored task of typedecay_t<F>
and a shared state . Initializesand initializesthe object's stored task withstd::forward<F>(f)
.