std::experi...amentalsTS)(3)
π NAME π
std::experimental::packaged_task::packaged_task(libraryfundamentalsTS) - std::experimental::packaged_task::packaged_task(libraryfundamentalsTS)
okay so welcome to the C++ Standard Libary corner of cppreference β yes, βLibary,β typo preserved, itβs iconic π
β and this is the constructor page for the library fundamentals TS version of std::experimental::packaged_task. Itβs giving βfive overloads and main character energy,β fr fr. β¨
π¦ Synopsis π¦
packaged_task() noexcept; (1) (library
fundamentals TS)
template< class F > (2) (library
fundamentals TS)
explicit packaged_task( F&& f );
template< class F, class Allocator >
explicit packaged_task( std::allocator_arg_t, const (3) (library
Allocator& alloc, F&& f );
packaged_task( const packaged_task& ) = delete; (4) (library
fundamentals TS)
packaged_task( packaged_task&& rhs ) noexcept; (5) (library
fundamentals TS)
Constructs a new std::experimental::packaged_task object. Bestie, thatβs the whole vibe, but hereβs the breakdown so you know exactly which overload is doing what π
- Constructs a
std::experimental::packaged_taskobject with no task and no shared state. - Constructs a
std::experimental::packaged_taskobject with a shared state and a copy of the task, initialized withstd::forward<F>(f). This constructor does not participate in overload resolution ifstd::decay<F>::typeis the same type asstd::packaged_task<R(ArgTypes...)>. - Constructs a
std::experimental::packaged_taskobject with a shared state and a copy of the task, initialized withstd::forward<F>(f). Uses the provided allocator to allocate memory necessary to store the task, which is treated as a type-erased allocator (see below). This constructor does not participate in overload resolution ifstd::decay<F>::typeis the same type asstd::packaged_task<R(ArgTypes...)>. - The copy constructor is deleted,
std::experimental::packaged_taskis move-only. - Constructs a
std::experimental::packaged_taskwith the shared state and task formerly owned byrhs, leavingrhswith no shared state and a moved-from task.
π§ Type-erased allocator π§
The constructors of packaged_task taking an allocator argument alloc treats that argument as a type-erased allocator. The memory resource pointer used by packaged_task to allocate memory is determined using the allocator argument (if specified) as follows:
- Type of
alloc: Non-existent (no allocator specified at time of construction). Value of the memory resource pointer: The value ofstd::experimental::pmr::get_default_resource()at time of construction. - Type of
alloc:std::nullptr_t. Value of the memory resource pointer: The value ofstd::experimental::pmr::get_default_resource()at time of construction. - Type of
alloc: A pointer type convertible tostd::experimental::pmr::memory_resource*. Value of the memory resource pointer:static_cast<std::experimental::pmr::memory_resource*>(alloc). - Type of
alloc:std::experimental::pmr::memory_resource*. Value of the memory resource pointer:alloc. - Type of
alloc: A specialization ofstd::experimental::pmr::polymorphic_allocator. Value of the memory resource pointer:alloc.resource(). - Type of
alloc: Any other type meeting theAllocatorrequirements. Value of the memory resource pointer: A pointer to a value of typestd::experimental::pmr::resource_adaptor<A>(alloc), whereAis the type ofalloc. The pointer remains valid only for the lifetime of thepackaged_taskobject. - Type of
alloc: None of the above. Value of the memory resource pointer: The program is ill-formed.
π Parameters π
fβ the callable target (function, member function, lambda-expression, functor) to execute.allocβ the allocator to use when storing the task.rhsβ thestd::experimental::packaged_taskto move from.
π Exceptions π
2,3)β Any exceptions thrown by copy/move constructor offandpossibllystd::bad_allocif the allocation fails.4)β (none).
source: http://cppreference.com Β· version/date: 2024.06.10 Β· page: std::experi...amentalsTS)(3) β k bye bestie, go construct responsibly πβ¨π«Ά
π¦ 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