deductiongu...ckaged_task(3)
π deductionguidesforstd::packaged_task π
okay so bestie, welcome to the deductionguidesforstd::packaged_task page from the C++ Standard Libary manual β yep, thatβs the manual name as it appears up top, iykyk π this is the C++ Standard Libary deduction-guides situation, and weβre gonna get through it together.
π NAME π
deductionguidesforstd::packaged_task β deductionguidesforstd::packaged_task. thatβs the name, no cap, periodt. π
πΈ Synopsis πΈ
Defined in header <future>
template< class R, class... Args > (1)
(since C++17)
packaged_task( R(*)(Args...) ) -> packaged_task<R(Args...)>;
template< class F > (2)
(since C++17)
packaged_task( F ) -> packaged_task</*see below*/>;
template< class F > (3)
(since C++23)
packaged_task( F ) -> packaged_task</*see below*/>;
template< class F > (4)
(since C++23)
packaged_task( F ) -> packaged_task</*see below*/>;
okay so hereβs the lineup, bestie β four whole deduction guides, each with its own vibe check πβ¨
- This deduction guide is provided for
std::packaged_taskto allow deduction from functions. thatβs literally its whole job, and it ate. π«Ά - This overload participates in overload resolution only if
&F::operator()is well-formed when treated as an unevaluated operand anddecltype(&F::operator())is of the formR(G::*)(A...)(optionally cv-qualified, optionally noexcept, optionally lvalue reference qualified). The deduced type isstd::packaged_task<R(A...)>. yes, thatβs a lot ofoptionally, but we respect theoptionallyπ - This overload participates in overload resolution only if
&F::operator()is well-formed when treated as an unevaluated operand andF::operator()is an explicit object parameter function whose type is of formR(G, A...)orR(G, A...) noexcept. The deduced type isstd::packaged_task<R(A...)>. explicit object parameter function era, we love to see it π - This overload participates in overload resolution only if
&F::operator()is well-formed when treated as an unevaluated operand andF::operator()is a static member function whose type is of formR(A...)orR(A...) noexcept. The deduced type isstd::packaged_task<R(A...)>. static member function representation, iconic behavior β
π¦ Notes π¦
β οΈ important vibe check: these deduction guides do not allow deduction from a function with ellipsis parameter, and the ... in the types is always treated as a pack expansion. thatβs not a maybe, thatβs the rule. π
π Example π
// Run this code
#include <future>
int func(double) { return 0; }
int main()
{
std::packaged_task f{func}; // deduces packaged_task<int(double)>
int i = 5;
std::packaged_task g = [&](double) { return i; }; // => packaged_task<int(double)>
}
alright bestie, thatβs the whole page! π«Ά source/version: http://cppreference.com; date: 2024.06.10. the footer also had deductiongu...ckaged_task(3) on it, but we already shouted out the title up top. mwah! πβ¨π
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms