std::packaged_task::packaged_task
来自cppreference.com
< cpp | thread | packaged task
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
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 移动。 |
[编辑] 。例外。
1)2-3) Any exceptions thrown by copy/move constructor of f
and possiblly std::bad_alloc if the allocation fails.
[编辑] 。为例。
本章尚未完成 原因:暂无示例 |