From da9b280f602ac53c84807164b44fbc9835304127 Mon Sep 17 00:00:00 2001 From: tzcnt Date: Sat, 27 Jun 2026 09:33:06 -0700 Subject: [PATCH 1/2] comments / formatting only --- include/tmc/detail/concepts_awaitable.hpp | 28 +++-- include/tmc/spawn_tuple.hpp | 132 ++++++++-------------- 2 files changed, 63 insertions(+), 97 deletions(-) diff --git a/include/tmc/detail/concepts_awaitable.hpp b/include/tmc/detail/concepts_awaitable.hpp index 50e857d1..64626b77 100644 --- a/include/tmc/detail/concepts_awaitable.hpp +++ b/include/tmc/detail/concepts_awaitable.hpp @@ -21,8 +21,7 @@ template struct await_resume_t_impl { using type = unknown_t; }; template struct await_resume_t_impl { - using type = - std::remove_reference_t().await_resume())>; + using type = std::remove_reference_t().await_resume())>; }; /// end await_resume_t_impl @@ -39,9 +38,7 @@ template struct unknown_awaitable_traits { template static decltype(auto) guess_awaiter(T&& value) { if constexpr (requires { static_cast(value).operator co_await(); }) { return static_cast(value).operator co_await(); - } else if constexpr (requires { - operator co_await(static_cast(value)); - }) { + } else if constexpr (requires { operator co_await(static_cast(value)); }) { return operator co_await(static_cast(value)); } else { return static_cast(value); @@ -97,6 +94,9 @@ using result_type = typename (result type of `co_await YourAwaitable;`); // Implementing this is OPTIONAL; if unimplemented, each awaitable will be // wrapped in a task that will automagically restore its executor and priority // before returning, thus preventing errors out-of-the-box. +// +// Setting the reference category of self_type (& or &&) controls whether this is an +rvalue-only or lvalue-only awaitable. static awaiter_type get_awaiter(self_type& Awaitable) { return awaiter_type(Awaitable); @@ -116,6 +116,9 @@ static constexpr configure_mode mode = COROUTINE; // If set to ASYNC_INITIATE, you must define this function, which will be // called to initiate the async process. The current TMC executor and priority // will be passed in, but they are not required to be used. +// +// Setting the reference category of Awaitable (& or &&) controls whether this is an +rvalue-only or lvalue-only awaitable. static constexpr configure_mode mode = ASYNC_INITIATE; static void async_initiate( @@ -147,8 +150,7 @@ static void set_flags(Awaitable& YourAwaitable, size_t Flags); */ template -using get_awaitable_traits = - awaitable_traits>; +using get_awaitable_traits = awaitable_traits>; template using awaitable_result_t = @@ -185,11 +187,9 @@ template struct awaitable_traits { struct AwaitTagNoGroupCoAwait {}; template -concept HasAwaitTagNoGroupCoAwait = - std::is_base_of_v; +concept HasAwaitTagNoGroupCoAwait = std::is_base_of_v; -template -struct awaitable_traits { +template struct awaitable_traits { static constexpr configure_mode mode = WRAPPER; static decltype(auto) get_awaiter(Awaitable&& awaitable) noexcept { @@ -211,8 +211,7 @@ template concept HasAwaitTagNoGroupCoAwaitLvalue = std::is_base_of_v; -template -struct awaitable_traits { +template struct awaitable_traits { static constexpr configure_mode mode = WRAPPER; static decltype(auto) get_awaiter(Awaitable& awaitable) noexcept { @@ -247,8 +246,7 @@ template struct range_iter { /// Given T&& -> holds T&& if T is not move-constructible template using forward_awaitable = std::conditional_t< - std::is_rvalue_reference_v && - std::is_move_constructible_v>, + std::is_rvalue_reference_v && std::is_move_constructible_v>, std::decay_t, T&&>; /// Must be defined by each TMC executor. No default implementation is provided. diff --git a/include/tmc/spawn_tuple.hpp b/include/tmc/spawn_tuple.hpp index b7019c40..7d8bd120 100644 --- a/include/tmc/spawn_tuple.hpp +++ b/include/tmc/spawn_tuple.hpp @@ -26,8 +26,7 @@ namespace tmc { namespace detail { // Replace void with std::monostate (void is not a valid tuple element type) template -using void_to_monostate = - std::conditional_t, std::monostate, T>; +using void_to_monostate = std::conditional_t, std::monostate, T>; // Get the last type of a parameter pack // In C++26 you can use pack indexing instead: T...[sizeof...(T) - 1] @@ -44,9 +43,7 @@ template using last_type_t = typename last_type::type; // Create 2 instantiations of the Variadic, one where all of the types // satisfy the predicate, and one where none of the types satisfy the predicate. -template < - template class Predicate, template class Variadic, - class...> +template