diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 6704c50..b2bdeb1 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -45,10 +45,10 @@ if(NOT MSVC) issue_affine cppnow_affinity cppnow_basic - # FIXME: cppnow_query + cppnow_query cppnow_result_types cppnow_return - # FIXME: cppnow_stop_token + cppnow_stop_token cppnow_with_error co_await_result co_await_task @@ -57,9 +57,9 @@ if(NOT MSVC) friendly hello issue_frame_allocator - # FIXME: query + query result_example - # FIXME: stop + stop ) endif() diff --git a/examples/cppnow_query.cpp b/examples/cppnow_query.cpp index e5c6ebc..757fae4 100644 --- a/examples/cppnow_query.cpp +++ b/examples/cppnow_query.cpp @@ -5,8 +5,7 @@ #include #include -namespace ex = beman::execution; -namespace exd = beman::execution::detail; +namespace ex = beman::execution; // ---------------------------------------------------------------------------- @@ -61,6 +60,6 @@ ex::task with_fancy_env() { } // namespace int main() { - ex::sync_wait(exd::write_env(with_env(), exd::make_env(get_value, 17))); - ex::sync_wait(exd::write_env(with_fancy_env(), exd::make_env(get_value, 17))); + ex::sync_wait(ex::write_env(with_env(), ex::detail::make_env(get_value, 17))); + ex::sync_wait(ex::write_env(with_fancy_env(), ex::detail::make_env(get_value, 17))); } diff --git a/examples/cppnow_stop_token.cpp b/examples/cppnow_stop_token.cpp index ae576c3..182e274 100644 --- a/examples/cppnow_stop_token.cpp +++ b/examples/cppnow_stop_token.cpp @@ -29,7 +29,7 @@ int main() { ex::inplace_stop_source source; std::thread thread([&] { - ex::sync_wait(ex::detail::write_env(stopping(), ex::detail::make_env(ex::get_stop_token, source.get_token()))); + ex::sync_wait(ex::write_env(stopping(), ex::detail::make_env(ex::get_stop_token, source.get_token()))); }); std::this_thread::sleep_for(100ms); diff --git a/examples/into_optional.cpp b/examples/into_optional.cpp index 2c83dde..03e186a 100644 --- a/examples/into_optional.cpp +++ b/examples/into_optional.cpp @@ -15,6 +15,10 @@ template struct multi_sender { using sender_concept = ex::sender_tag; using completion_signatures = ex::completion_signatures; + template + static consteval auto get_completion_signatures() { + return completion_signatures{}; + } template auto connect(Receiver&& receiver) const { @@ -69,8 +73,12 @@ auto my_into_optional(S&& s) { int main() { queue que; ex::sync_wait([](auto& q) -> ex::task<> { - // auto x = co_await ex::just(true) | into_optional; - [[maybe_unused]] std::optional x = co_await (q.async_pop() | ex::into_optional); - [[maybe_unused]] std::optional y = co_await ex::into_optional(q.async_pop()); + static_assert( + std::same_as())>); + // auto x = co_await (ex::just(true) | ex::into_optional); + // [[maybe_unused]] std::optional x = co_await (q.async_pop() | ex::into_optional); + // [[maybe_unused]] std::optional y = co_await ex::into_optional(q.async_pop()); + co_return; }(que)); } diff --git a/examples/query.cpp b/examples/query.cpp index c09bfaa..e3b5036 100644 --- a/examples/query.cpp +++ b/examples/query.cpp @@ -49,13 +49,13 @@ struct context { }; int main() { - ex::sync_wait(ex::detail::write_env( + ex::sync_wait(ex::write_env( []() -> ex::task { auto value(co_await ex::read_env(get_value)); std::cout << "value=" << value << "\n"; }(), ex::detail::make_env(get_value, 42))); - ex::sync_wait(ex::detail::write_env( + ex::sync_wait(ex::write_env( []() -> ex::task { auto value(co_await ex::read_env(get_value)); std::cout << "value=" << value << "\n"; diff --git a/examples/stop.cpp b/examples/stop.cpp index bfe5eff..74c4aad 100644 --- a/examples/stop.cpp +++ b/examples/stop.cpp @@ -33,7 +33,7 @@ int main() { }; }; - auto [result] = ex::sync_wait(ex::detail::write_env( + auto [result] = ex::sync_wait(ex::write_env( []() -> ex::task { auto token(co_await ex::read_env(ex::get_stop_token)); std::uint64_t count{}; diff --git a/include/beman/task/detail/into_optional.hpp b/include/beman/task/detail/into_optional.hpp index 7bef831..f5b4fce 100644 --- a/include/beman/task/detail/into_optional.hpp +++ b/include/beman/task/detail/into_optional.hpp @@ -15,8 +15,8 @@ namespace beman::task::detail { inline constexpr struct into_optional_t : beman::execution::sender_adaptor_closure { template <::beman::execution::sender Upstream> struct sender { - using upstream_t = std::remove_cvref_t; using sender_concept = ::beman::execution::sender_tag; + using upstream_t = std::remove_cvref_t; upstream_t upstream; template @@ -48,22 +48,25 @@ inline constexpr struct into_optional_t : beman::execution::sender_adaptor_closu } template - static auto get_type(Env&&) { + static consteval auto get_type() { return find_type( ::beman::execution::value_types_of_t, type_list, type_list>()); } - template - constexpr auto make_signatures(auto&& env, type_list, type_list) const { + template + static consteval auto make_signatures(type_list, type_list) { return ::beman::execution::completion_signatures<::beman::execution::set_value_t( - decltype(this->get_type(env))), + decltype(get_type())), ::beman::execution::set_error_t(E)..., S...>(); } - template - auto get_completion_signatures(Env&& env) const { - return make_signatures( - env, + template + static consteval auto get_completion_signatures() { + static_assert(::beman::execution::sender); + static_assert(::beman::execution::sender_in); + static_assert(::beman::execution::sender_in); + return make_signatures( + ::beman::execution::value_types_of_t, type_list>{}, ::beman::execution::error_types_of_t, type_list>{}, std::conditional_t<::beman::execution::sends_stopped>, type_list<::beman::execution::set_stopped_t()>, @@ -73,7 +76,7 @@ inline constexpr struct into_optional_t : beman::execution::sender_adaptor_closu struct make_object { template auto operator()(A&&... a) const - -> decltype(get_type(::beman::execution::get_env(std::declval()))) { + -> decltype(get_type()))>()) { if constexpr (sizeof...(A) == 0u) return {}; else