Compartir a través de


packaged_task::packaged_task Constructor

Constructs a packaged_task object.

packaged_task() noexcept;
packaged_task(packaged_task&& Right) noexcept;
template<class Fn>
   explicit packaged_task(Fn&& fn);
template<class Fn, class Alloc>
   explicit packaged_task(allocator_arg_t,
      const Alloc& alloc, Fn&& fn);

Parameters

  • Right
    A packaged_task object.

  • alloc
    A memory allocator. For more information, see <allocators>.

  • fn
    A function object.

Remarks

The first constructor constructs a packaged_task object that has no associated asynchronous state.

The second constructor constructs a packaged_task object and transfers the associated asynchronous state from Right. After the operation, Right no longer has an associated asynchronous state.

The third constructor constructs a packaged_task object that has a copy of fn stored in its associated asynchronous state.

The fourth constructor constructs a packaged_task object that has a copy of fn stored in its associated asynchronous state, and uses alloc for memory allocation.

Requirements

Header: future

Namespace: std

See Also

Reference

packaged_task Class

<future>