From 8e316bf51002dd4fa6a7638b5ac849e83399787c Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Mon, 23 Nov 2026 11:37:22 -0800 Subject: [PATCH] port `just`, `just_error`, and `just_stopped` to the sender facade Co-Authored-By: Claude Opus 5.5 --- include/stdexec/__detail/__just.hpp | 65 ++++++++--------------------- test/stdexec/detail/test_facade.cpp | 8 +++- 2 files changed, 24 insertions(+), 49 deletions(-) diff --git a/include/stdexec/__detail/__just.hpp b/include/stdexec/__detail/__just.hpp index 7b5aeb3be..430662841 100644 --- a/include/stdexec/__detail/__just.hpp +++ b/include/stdexec/__detail/__just.hpp @@ -25,13 +25,9 @@ import stdexec; # include "__execution_fwd.hpp" -# include "__basic_sender.hpp" # include "__completion_behavior.hpp" -# include "__completion_signatures.hpp" -# include "__meta.hpp" -# include "__receivers.hpp" -# include "__sender_introspection.hpp" -# include "__type_traits.hpp" +# include "__sender_facade.hpp" +# include "__tuple.hpp" # include "__prologue.hpp" @@ -53,44 +49,19 @@ namespace STDEXEC } }; - template - struct __opstate - { - constexpr void start() noexcept - { - __apply(_SetTag(), static_cast<_Tuple&&>(__data_), static_cast<_Receiver&&>(__rcvr_)); - } - - _Receiver __rcvr_; - _Tuple __data_; - }; - - template - struct __impl : __sexpr_defaults + // just(vs...), just_error(err), and just_stopped() complete inline, from start() + template + struct __algo : __facade::__defaults { - using __set_tag_t = _JustTag::__tag_t; - - static constexpr auto __get_attrs = [](__ignore, __ignore) noexcept -> __attrs<__set_tag_t> - { - return {}; - }; - - template - static consteval auto __get_completion_signatures() + template + STDEXEC_ATTRIBUTE(always_inline, host, device) + static constexpr auto __start(_State& __state, _Children&) noexcept { - static_assert(__sender_for<_Sender, _JustTag>); - return completion_signatures<__mapply<__qf<__set_tag_t>, __decay_t<__data_of<_Sender>>>>{}; + return STDEXEC::__apply( + [&](_Ts&&... __vs) noexcept + { return __facade::__send(__state.__rcvr_, _SetTag(), static_cast<_Ts&&>(__vs)...); }, + static_cast(__state.__data_)); } - - static constexpr auto __connect = - [](_Sender&& __sndr, _Receiver&& __rcvr) noexcept( - __nothrow_decay_copyable<_Sender>) - { - auto& [__tag, __data] = __sndr; - return __opstate<__set_tag_t, decltype(__data), _Receiver>{static_cast<_Receiver&&>(__rcvr), - STDEXEC::__forward_like<_Sender>( - __data)}; - }; }; } // namespace __just @@ -172,11 +143,11 @@ namespace STDEXEC }; template <> - struct __sexpr_impl : __just::__impl + struct __facade::__algorithm : __just::__algo {}; template - struct just_t::__sender : __sexpr> + struct just_t::__sender : __facade::__sender> {}; //! @brief Construct a sender that synchronously value-completes with the @@ -254,11 +225,11 @@ namespace STDEXEC }; template <> - struct __sexpr_impl : __just::__impl + struct __facade::__algorithm : __just::__algo {}; template - struct just_error_t::__sender : __sexpr> + struct just_error_t::__sender : __facade::__sender> {}; //! @brief Construct a sender that synchronously error-completes with the @@ -325,10 +296,10 @@ namespace STDEXEC }; template <> - struct __sexpr_impl : __just::__impl + struct __facade::__algorithm : __just::__algo {}; - struct just_stopped_t::__sender : __sexpr> + struct just_stopped_t::__sender : __facade::__sender> {}; //! @brief Construct a sender that synchronously stops-completes. diff --git a/test/stdexec/detail/test_facade.cpp b/test/stdexec/detail/test_facade.cpp index 6a9914b3b..3eab58962 100644 --- a/test/stdexec/detail/test_facade.cpp +++ b/test/stdexec/detail/test_facade.cpp @@ -15,8 +15,8 @@ */ // Tests for the sender facade in , through algorithms -// that are written with it for the tests. None of them has hand-written completion -// signatures or hand-written completion attributes. +// that are written with it: some for the tests, and the library's own. None of them has +// hand-written completion signatures or hand-written completion attributes. // Catch2 must come before any potential import statements #include @@ -357,6 +357,10 @@ namespace static_assert( !ex::__well_formed_sender); + ////////////////////////////////////////////////////////////////////////////////////////// + // 1. Completion signatures fall out of the code. + static_assert(has_sigs_v); + ////////////////////////////////////////////////////////////////////////////////////////// // Run-time tests