From 6f64c1136282055cdce3580af9d17512e70ab1fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dietmar=20K=C3=BChl?= Date: Fri, 30 Aug 2024 16:20:14 +0100 Subject: [PATCH] some progress on basic_sender --- .../beman/execution26/detail/basic_sender.hpp | 37 +++++++++++++++++ .../beman/execution26/detail/product_type.hpp | 13 ++++++ .../execution26/detail/sender_decompose.hpp | 25 +++++++++--- .../tests/exec-snd-concepts.pass.cpp | 32 +++++++++++++++ .../execution26/tests/exec-snd-expos.pass.cpp | 40 +++++++++++++++++-- 5 files changed, 139 insertions(+), 8 deletions(-) diff --git a/include/beman/execution26/detail/basic_sender.hpp b/include/beman/execution26/detail/basic_sender.hpp index f44b37d4..30525794 100644 --- a/include/beman/execution26/detail/basic_sender.hpp +++ b/include/beman/execution26/detail/basic_sender.hpp @@ -4,6 +4,8 @@ #ifndef INCLUDED_BEMAN_EXECUTION26_DETAIL_BASIC_SENDER #define INCLUDED_BEMAN_EXECUTION26_DETAIL_BASIC_SENDER +#include +#include #include // ---------------------------------------------------------------------------- @@ -14,6 +16,41 @@ namespace beman::execution26::detail struct basic_sender { using sender_concept = ::beman::execution26::sender_t; + +#if __cpp_explicit_this_parameter < 302110L + template + auto get_completion_signatures(Env&&) && noexcept + -> ::beman::execution26::detail::completion_signatures_for + { + return {}; + } + template + auto get_completion_signatures(Env&&) const&& noexcept + -> ::beman::execution26::detail::completion_signatures_for + { + return {}; + } + template + auto get_completion_signatures(Env&&) & noexcept + -> ::beman::execution26::detail::completion_signatures_for + { + return {}; + } + template + auto get_completion_signatures(Env&&) const& noexcept + -> ::beman::execution26::detail::completion_signatures_for + { + return {}; + } +#else + template <::beman::execution26::detail::decays_to Self, + typename Env> + auto get_completion_signatures(this Self&&, Env&&) noexcept + -> ::beman::execution26::detail::completion_signatures_for + { + return {}; + } +#endif }; } diff --git a/include/beman/execution26/detail/product_type.hpp b/include/beman/execution26/detail/product_type.hpp index 8bb0da36..42889c23 100644 --- a/include/beman/execution26/detail/product_type.hpp +++ b/include/beman/execution26/detail/product_type.hpp @@ -73,6 +73,19 @@ namespace beman::execution26::detail T4 value4; T5 value5; }; + + template + struct product_type + { + static constexpr ::std::size_t size{6u}; + auto operator== (product_type const&) const -> bool = default; + T1 value1; + T2 value2; + T3 value3; + T4 value4; + T5 value5; + T6 value6; + }; } // ---------------------------------------------------------------------------- diff --git a/include/beman/execution26/detail/sender_decompose.hpp b/include/beman/execution26/detail/sender_decompose.hpp index e7fa1ecb..e4c99cda 100644 --- a/include/beman/execution26/detail/sender_decompose.hpp +++ b/include/beman/execution26/detail/sender_decompose.hpp @@ -43,27 +43,42 @@ namespace beman::execution26::detail #endif using sender_type = ::std::remove_cvref_t; static constexpr ::beman::execution26::detail::sender_any_t at{}; - if constexpr (requires(){ sender_type{ at, at, at, at, at, at }; }) + if constexpr ( + requires(){ sender_type{ at, at, at, at, at, at }; } + || requires(){ sender_type{ { at, at, at, at, at, at } }; } + ) { auto&& [tag, data, c0, c1, c2, c3] = sender; return ::beman::execution26::detail::sender_meta>{}; } - else if constexpr (requires(){ sender_type{ at, at, at, at, at }; }) + else if constexpr ( + requires(){ sender_type{ at, at, at, at, at }; } + || requires(){ sender_type{ { at, at, at, at, at } }; } + ) { auto&& [tag, data, c0, c1, c2] = sender; return ::beman::execution26::detail::sender_meta>{}; } - else if constexpr (requires(){ sender_type{ at, at, at, at }; }) + else if constexpr ( + requires(){ sender_type{ at, at, at, at }; } + || requires(){ sender_type{ { at, at, at, at } }; } + ) { auto&& [tag, data, c0, c1] = sender; return ::beman::execution26::detail::sender_meta>{}; } - else if constexpr (requires(){ sender_type{ at, at, at }; }) + else if constexpr ( + requires(){ sender_type{ at, at, at }; } + || requires(){ sender_type{ { at, at, at } }; } + ) { auto&& [tag, data, c0] = sender; return ::beman::execution26::detail::sender_meta>{}; } - else if constexpr (requires(){ sender_type{ at, at }; }) + else if constexpr ( + requires(){ sender_type{ at, at }; } + || requires(){ sender_type{ { at, at } }; } + ) { auto&& [tag, data] = sender; return ::beman::execution26::detail::sender_meta>{}; diff --git a/src/beman/execution26/tests/exec-snd-concepts.pass.cpp b/src/beman/execution26/tests/exec-snd-concepts.pass.cpp index 445c7032..f442c73c 100644 --- a/src/beman/execution26/tests/exec-snd-concepts.pass.cpp +++ b/src/beman/execution26/tests/exec-snd-concepts.pass.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include +#include #include #include #include @@ -61,6 +62,31 @@ namespace int child3; int child4; }; + struct product_sender0 + : test_detail::product_type + { + using sender_concept = test_std::sender_t; + }; + struct product_sender1 + : test_detail::product_type + { + using sender_concept = test_std::sender_t; + }; + struct product_sender2 + : test_detail::product_type + { + using sender_concept = test_std::sender_t; + }; + struct product_sender3 + : test_detail::product_type + { + using sender_concept = test_std::sender_t; + }; + struct product_sender4 + : test_detail::product_type + { + using sender_concept = test_std::sender_t; + }; // ------------------------------------------------------------------------- @@ -133,6 +159,12 @@ namespace static_assert(std::same_as>); static_assert(std::same_as>); static_assert(std::same_as>); + + static_assert(std::same_as>); + static_assert(std::same_as>); + static_assert(std::same_as>); + static_assert(std::same_as>); + static_assert(std::same_as>); } auto test_sender_for() -> void diff --git a/src/beman/execution26/tests/exec-snd-expos.pass.cpp b/src/beman/execution26/tests/exec-snd-expos.pass.cpp index 1f72e8de..79eeb54e 100644 --- a/src/beman/execution26/tests/exec-snd-expos.pass.cpp +++ b/src/beman/execution26/tests/exec-snd-expos.pass.cpp @@ -1063,15 +1063,49 @@ namespace test_detail::no_completion_signatures_defined_in_sender >); } + + struct basic_sender_tag + { + struct sender + { + using sender_concept = test_std::sender_t; + using completion_signatures = test_std::completion_signatures<>; + }; + auto transform_sender(auto&&...) noexcept { return sender{}; } + }; auto test_basic_sender() -> void { - struct tag {}; struct data {}; struct env {}; + struct tagged_sender + : test_detail::product_type + { + using sender_concept = test_std::sender_t; + }; + +#if 1 + auto&&[a, b, c] = tagged_sender{basic_sender_tag{}, data{}, sender0{}}; + use(a); + use(b); + use(c); +#endif + + static_assert(test_std::sender); + static_assert(test_std::sender_in); + static_assert(test_std::sender_in); + static_assert(test_std::sender); + static_assert(std::same_as< + basic_sender_tag, + test_std::tag_of_t + >); + //static_assert(std::same_as< + // basic_sender_tag::sender, + // decltype(test_std::transform_sender(test_std::default_domain{}, tagged_sender{}, env{})) + //>); - using basic_sender = test_detail::basic_sender; + using basic_sender = test_detail::basic_sender; static_assert(test_std::sender); - //-dk:TODO static_assert(test_std::sender_in); + //static_assert(test_std::sender_in); } }