Defined in <stlab/concurrency/task.hpp>
template <class>
class task; /* undefined */
template <class R, class... Args>
class task<R(Args...)>

Class template stlab::task is a general-purpose polymorphic function wrapper. Instances of stlab::task can store, move, and invoke any Callable target – functions, lambda expressions, bind expressions, or other function objects, as well as pointers to member functions and pointers to data members.

The stored callable object is called the target of stlab::task. If an stlab::task contains no target, it is called empty. Invoking the target of an empty stlab::task results in std::bad_function_call exception being thrown.

stlab::task is Similar to std::function except it is not copyable and supports move-only and mutable callable targets which is especially useful for targets that may only be invoked once, often useful to deliver a message or payload in tasking or messaging system.

stlab::task satisfies the requirements of MoveConstructible and MoveAssignable.

Member types

Member type Definition
result_type R

Member Functions

(constructor) Constructs a task
(destructor) Default-destructs a task

Associated Functions

Compares a task for not equal an empty task

Checks if a given task is equal to an empty task

(template function)

Exchanges two tasks

Associated Classes

A type-erased nullary wrapper that supports mutable functions.

(template class)