.. _spawn_clang:

tmc::spawn_clang()
------------------------------------------------------------------------------------------------
``tmc::spawn_clang()`` is a HALO-optimized version of ``spawn()`` that uses the ``[[clang::coro_await_elidable_argument]]`` attribute when compiled with Clang 20+.

Like ``spawn()``, it does not affect the task unless you specify one of the optional parameters. Its
only purpose is to allow you to run work on a different executor or priority without incurring an allocation.

For HALO to work, ``spawn_clang()`` must be awaited directly as a prvalue in a ``co_await`` expression. Storing the result in a variable before awaiting prevents HALO from being applied.

.. code-block:: cpp

   // HALO: spawn_clang() is directly awaited
   auto result = co_await tmc::spawn_clang(some_task(), some_executor());

   // Non-HALO: spawn_clang() stored in variable
   auto spawned = tmc::spawn_clang(some_task(), some_executor());
   auto result = co_await std::move(spawned);

Main Documentation
------------------------------------------------------------------------------------------------
For the non-HALO version, see :literal_ref:`tmc::spawn()<spawn>`.

API Reference
------------------------------------------------------------------------------------------------
.. doxygenfunction:: tmc::spawn_clang(Awaitable&& Aw, Exec&& Executor, size_t Priority)
