Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      deduction guides forstd::packaged_task

      From cppreference.com
      <cpp‎ |thread‎ |packaged task
       
       
      Concurrency support library
      Threads
      (C++11)
      (C++20)
      this_thread namespace
      (C++11)
      (C++11)
      (C++11)
      Cooperative cancellation
      Mutual exclusion
      Generic lock management
      (C++11)
      (C++11)
      (C++11)
      (C++11)
      Condition variables
      (C++11)
      Semaphores
      Latches and Barriers
      (C++20)
      (C++20)
      Futures
      (C++11)
      (C++11)
      (C++11)
      Safe reclamation
      Hazard pointers
      Atomic types
      (C++11)
      (C++20)
      Initialization of atomic types
      (C++11)(deprecated in C++20)
      (C++11)(deprecated in C++20)
      Memory ordering
      (C++11)(deprecated in C++26)
      Free functions for atomic operations
      Free functions for atomic flags
       
       
      Defined in header<future>
      template<class R,class...Args>
      packaged_task( R(*)(Args...))-> packaged_task<R(Args...)>;
      (1)(since C++17)
      template<class F>
      packaged_task( F)-> packaged_task</*see below*/>;
      (2)(since C++17)
      template<class F>
      packaged_task( F)-> packaged_task</*see below*/>;
      (3)(since C++23)
      template<class F>
      packaged_task( F)-> packaged_task</*see below*/>;
      (4)(since C++23)
      1) Thisdeduction guide is provided forstd::packaged_task to allow deduction from functions.
      2) 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...)>.
      3) This overload participates in overload resolution only if&F::operator() is well-formed when treated as an unevaluated operand andF::operator() is anexplicit object parameter function whose type is of formR(G, A...) orR(G, A...)noexcept. The deduced type isstd::packaged_task<R(A...)>.
      4) This overload participates in overload resolution only if&F::operator() is well-formed when treated as an unevaluated operand andF::operator() is astatic member function whose type is of formR(A...) orR(A...)noexcept. The deduced type isstd::packaged_task<R(A...)>.

      [edit]Notes

      These deduction guides do not allow deduction from a function withellipsis parameter, and the... in the types is always treated as apack expansion.

      [edit]Example

      Run this code
      #include <future> int func(double){return0;} 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)>}
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/thread/packaged_task/deduction_guides&oldid=161748"

      [8]ページ先頭

      ©2009-2025 Movatter.jp