tmc::task#
tmc::task<Result> supports HALO when used with Clang 20+ via the [[clang::coro_await_elidable]] attribute.
For HALO to work, the task coroutine function must be awaited directly as a prvalue in a co_await expression. Storing the task in a variable before awaiting prevents HALO from being applied.
// HALO: This allocation can be elided as it is directly awaited
auto result = co_await task_int(1);
// Non-HALO: This allocation cannot be elided as it is stored in a
// variable before being awaited
auto t = task_int(2);
auto result = co_await std::move(t);
// Non-HALO: This allocation cannot be elided because the .resume_on()
// member function call breaks Clang's requirement that it be
// an "immediate right-hand side operand to a co_await expression"
auto result = co_await task_int(2).resume_on(tmc::current_executor());
Main Documentation#
For full documentation on tmc::task, see tmc::task.