std::packaged_task::packaged_task

来自cppreference.com

 
 
线程支持库
线程
(C++11)
this_thread 命名空间
(C++11)
(C++11)
(C++11)
互斥
(C++11)
通用锁管理
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
条件变量
(C++11)
期货
(C++11)
(C++11)
(C++11)
(C++11)
 
std::packaged_task
成员函数
原文:
Member functions
文本通过谷歌翻译机器翻译。
你可以帮忙校正和验证翻译。点击此处查看指示。
packaged_task::packaged_task
获得的结果
原文:
Getting the result
文本通过谷歌翻译机器翻译。
你可以帮忙校正和验证翻译。点击此处查看指示。
执行
原文:
Execution
文本通过谷歌翻译机器翻译。
你可以帮忙校正和验证翻译。点击此处查看指示。
 
packaged_task()
(1)
template <class F>
explicit packaged_task(F&& f)
(2)
template <class F, class Allocator>
explicit packaged_task(std::allocator_arg_t, const Allocator& a, F&& f)
(3)
packaged_task(const packaged_task&) = delete
(4)
packaged_task(packaged_task&& rhs)
(5)
1) Constructs a std::packaged_task object with no task and no shared state.
2) Constructs a std::packaged_task object with a shared state and a copy of the task, initialized with std::forward<F>(f).
3) Constructs a std::packaged_task object with a shared state and a copy of the task, initialized with std::forward<F>(f). Uses the provided allocator to allocate memory necessary to store the task.
4) The copy constructor is deleted, std::packaged_task is move-only.
。注意:C + +11不指定const在这里,这是defect 2067.
原文:
Note: C++11 does not specify const here, this is the defect 2067.
文本通过谷歌翻译机器翻译。
你可以帮忙校正和验证翻译。点击此处查看指示。
5) Constructs a std::packaged_task with the shared state and task formerly owned by rhs, leaving rhs with no shared state and a moved-from task.

[编辑] 。参数。

f - the callable target (function, member function, lambda-expression, functor) to execute
a - the allocator to use when storing the task
rhs -
std::packaged_task移动。
原文:
the std::packaged_task to move from
文本通过谷歌翻译机器翻译。
你可以帮忙校正和验证翻译。点击此处查看指示。

[编辑] 。例外。

1)
noexcept 规定:  
noexcept
  

2-3) Any exceptions thrown by copy/move constructor of f and possiblly std::bad_alloc if the allocation fails.

5)
noexcept 规定:  
noexcept
  

[编辑] 。为例。