From c81a1599f14a651829f09def1e9ccb3cc6fd747a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dietmar=20K=C3=BChl?= Date: Sun, 10 Aug 2025 22:21:49 +0100 Subject: [PATCH 1/2] removed some lambda uses from headers --- include/beman/task/detail/handle.hpp | 10 ++++---- include/beman/task/detail/into_optional.hpp | 23 +++++++++++-------- .../task/detail/single_thread_context.hpp | 5 +++- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/include/beman/task/detail/handle.hpp b/include/beman/task/detail/handle.hpp index 276bdfe..b1d9471 100644 --- a/include/beman/task/detail/handle.hpp +++ b/include/beman/task/detail/handle.hpp @@ -15,11 +15,13 @@ namespace beman::task::detail { template class handle { private: - using deleter = decltype([](auto p) { - if (p) { - std::coroutine_handle

::from_promise(*p).destroy(); + struct deleter { + auto operator()(P* p) noexcept -> void { + if (p) { + std::coroutine_handle

::from_promise(*p).destroy(); + } } - }); + }; std::unique_ptr h; public: diff --git a/include/beman/task/detail/into_optional.hpp b/include/beman/task/detail/into_optional.hpp index e57055a..d891089 100644 --- a/include/beman/task/detail/into_optional.hpp +++ b/include/beman/task/detail/into_optional.hpp @@ -48,7 +48,7 @@ inline constexpr struct into_optional_t : beman::execution::sender_adaptor_closu } template - auto get_type(Env&&) const { + static auto get_type(Env&&) { return find_type( ::beman::execution::value_types_of_t, type_list, type_list>()); } @@ -69,18 +69,21 @@ inline constexpr struct into_optional_t : beman::execution::sender_adaptor_closu type_list<::beman::execution::set_stopped_t()>, type_list<>>{}); } - + template + struct make_object { + template + auto operator()(A&&... a) const + -> decltype(get_type(::beman::execution::get_env(std::declval()))) { + if constexpr (sizeof...(A) == 0u) + return {}; + else + return {std::forward(a)...}; + } + }; template auto connect(Receiver&& receiver) && { return ::beman::execution::connect( - ::beman::execution::then( - std::move(this->upstream), - [](A&&... a) -> decltype(get_type(::beman::execution::get_env(receiver))) { - if constexpr (sizeof...(A) == 0u) - return {}; - else - return {std::forward(a)...}; - }), + ::beman::execution::then(std::move(this->upstream), make_object{}), std::forward(receiver)); } }; diff --git a/include/beman/task/detail/single_thread_context.hpp b/include/beman/task/detail/single_thread_context.hpp index 541f7f8..f6b0aea 100644 --- a/include/beman/task/detail/single_thread_context.hpp +++ b/include/beman/task/detail/single_thread_context.hpp @@ -5,6 +5,7 @@ #define INCLUDED_INCLUDE_BEMAN_TASK_DETAIL_SINGLE_THREAD_CONTEXT #include +#include #include // ---------------------------------------------------------------------------- @@ -13,7 +14,9 @@ namespace beman::task::detail { class single_thread_context { private: ::beman::execution::run_loop loop; - ::std::thread thread{[this] { this->loop.run(); }}; + ::std::thread thread{&single_thread_context::run, this}; + + static auto run(single_thread_context* self) -> void { self->loop.run(); } public: single_thread_context() = default; From 0ee33d23f0fb935dc422bf8828ab7bc02c0060b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dietmar=20K=C3=BChl?= Date: Sun, 10 Aug 2025 22:24:21 +0100 Subject: [PATCH 2/2] Update include/beman/task/detail/into_optional.hpp Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- include/beman/task/detail/into_optional.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/beman/task/detail/into_optional.hpp b/include/beman/task/detail/into_optional.hpp index d891089..04488aa 100644 --- a/include/beman/task/detail/into_optional.hpp +++ b/include/beman/task/detail/into_optional.hpp @@ -72,8 +72,8 @@ inline constexpr struct into_optional_t : beman::execution::sender_adaptor_closu template struct make_object { template - auto operator()(A&&... a) const - -> decltype(get_type(::beman::execution::get_env(std::declval()))) { + auto + operator()(A&&... a) const -> decltype(get_type(::beman::execution::get_env(std::declval()))) { if constexpr (sizeof...(A) == 0u) return {}; else