From 6ffe548f8c708286f9c430ad5fbcc769cb7d2b50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dietmar=20K=C3=BChl?= Date: Mon, 2 Feb 2026 23:26:45 +0000 Subject: [PATCH 1/9] saving current state --- examples/CMakeLists.txt | 1 + src/beman/execution/execution.cppm | 6466 +------------------------- tests/beman/execution/CMakeLists.txt | 1 + 3 files changed, 8 insertions(+), 6460 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index c68e6e17..c5bfc674 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -33,6 +33,7 @@ set(EXAMPLES stopping when_all-cancel ) +set(EXAMPLES) if(BEMAN_USE_MODULES) list(APPEND EXAMPLES modules) # modules.cpp diff --git a/src/beman/execution/execution.cppm b/src/beman/execution/execution.cppm index e54eb38a..a30cef80 100644 --- a/src/beman/execution/execution.cppm +++ b/src/beman/execution/execution.cppm @@ -5,6468 +5,14 @@ module; // *****************************************************; // generated by ./bin/mk-module.py src/beman/execution/execution.cppm -#include -#include - -#ifdef BEMAN_HAS_IMPORT_STD -import std; -#else -#line 239 "./bin/mk-module.py" -#include -#line 239 "./bin/mk-module.py" -#include -#line 239 "./bin/mk-module.py" -#include -#line 239 "./bin/mk-module.py" -#include -#line 239 "./bin/mk-module.py" -#include -#line 239 "./bin/mk-module.py" -#include -#line 239 "./bin/mk-module.py" -#include -#line 239 "./bin/mk-module.py" -#include -#line 239 "./bin/mk-module.py" -#include -#line 239 "./bin/mk-module.py" -#include -#line 239 "./bin/mk-module.py" -#include -#line 239 "./bin/mk-module.py" -#include -#line 239 "./bin/mk-module.py" -#include -#line 239 "./bin/mk-module.py" -#include -#line 239 "./bin/mk-module.py" -#include -#line 239 "./bin/mk-module.py" -#include -#line 239 "./bin/mk-module.py" -#include -#line 239 "./bin/mk-module.py" -#include -#line 239 "./bin/mk-module.py" -#include -#endif +#include export module beman.execution; -#line 5 "include/beman/execution/execution.hpp" - -#line 9 "include/beman/execution/detail/common.hpp" -#ifndef BEMAN_EXECUTION_EXPORT -#define BEMAN_EXECUTION_EXPORT -#endif - -#if defined(disabled__cpp_deleted_function) -#define BEMAN_EXECUTION_DELETE(msg) delete (msg) -#else -#define BEMAN_EXECUTION_DELETE(msg) delete -#endif - -#line 43 "include/beman/execution/detail/common.hpp" -namespace beman { - -#line 54 "include/beman/execution/detail/common.hpp" -namespace execution { - -#line 61 "include/beman/execution/detail/common.hpp" -namespace detail {} -} // namespace execution -} // namespace beman - -#line 6 "include/beman/execution/detail/suppress_push.hpp" -#if defined(__GNUC__) -#define BEMAN_EXECUTION_DIAGNOSTIC_PUSHED -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wmissing-braces" -#pragma GCC diagnostic ignored "-Wmissing-field-initializers" -#endif - -#if defined(__clang__) -#define BEMAN_EXECUTION_DIAGNOSTIC_PUSHED -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wunknown-warning-option" -#pragma clang diagnostic ignored "-Wmissing-braces" -#pragma clang diagnostic ignored "-Wc++26-extensions" -#endif -#line 3 "include/beman/execution/detail/suppress_pop.hpp" - -#line 6 "include/beman/execution/detail/suppress_pop.hpp" -#ifdef BEMAN_EXECUTION_DIAGNOSTIC_PUSHED -#if defined(__GNUC__) -#pragma GCC diagnostic pop -#endif -#if defined(__clang__) -#pragma clang diagnostic pop -#endif -#undef BEMAN_EXECUTION_DIAGNOSTIC_PUSHED -#endif -#line 3 "include/beman/execution/detail/queryable.hpp" - -#line 12 "include/beman/execution/detail/queryable.hpp" -namespace beman::execution::detail { -template -concept queryable = ::std::destructible; -} -#line 14 "include/beman/execution/detail/forwarding_query.hpp" -namespace beman::execution::detail { - -#line 20 "include/beman/execution/detail/forwarding_query.hpp" -struct forwarding_query_t { - template - requires requires(Object&& object, const forwarding_query_t& query) { - { ::std::forward(object).query(query) } noexcept -> ::std::same_as; - } - constexpr auto operator()(Object&& object) const noexcept -> bool { - return ::std::forward(object).query(*this); - } - template - constexpr auto operator()(Object&&) const noexcept -> bool { - return ::std::derived_from<::std::remove_cvref_t, ::beman::execution::detail::forwarding_query_t>; - } -}; -} // namespace beman::execution::detail - -namespace beman::execution { - -#line 40 "include/beman/execution/detail/forwarding_query.hpp" -export /* --------- */ using forwarding_query_t = beman::execution::detail::forwarding_query_t; - -#line 53 "include/beman/execution/detail/forwarding_query.hpp" -export /* --------- */ inline constexpr forwarding_query_t forwarding_query{}; -} // namespace beman::execution - -#line 13 "include/beman/execution/detail/movable_value.hpp" -namespace beman::execution::detail { -template -concept movable_value = - ::std::move_constructible<::std::decay_t> && ::std::constructible_from<::std::decay_t, T> && - (!::std::is_array_v<::std::remove_reference_t>); -} -#line 12 "include/beman/execution/detail/matching_sig.hpp" -namespace beman::execution::detail { -template -struct matching_sig_transform { - using type = Fun; -}; -template -struct matching_sig_transform { - using type = Return(Args&&...); -}; - -template -inline constexpr bool matching_sig = - ::std::same_as::type, - typename ::beman::execution::detail::matching_sig_transform::type>; -} // namespace beman::execution::detail - -#line 17 "include/beman/execution/detail/as_except_ptr.hpp" -namespace beman::execution::detail { - -#line 23 "include/beman/execution/detail/as_except_ptr.hpp" -template -decltype(auto) as_except_ptr(Error&& error) { - if constexpr (::std::same_as<::std::exception_ptr, ::std::decay_t>) { - return ::std::forward(error); - } else if constexpr (::std::same_as<::std::error_code, ::std::decay_t>) { - return ::std::make_exception_ptr(::std::system_error(error)); - } else { - return ::std::make_exception_ptr(::std::forward(error)); - } -} -} // namespace beman::execution::detail - -#line 14 "include/beman/execution/detail/set_value.hpp" -namespace beman::execution { - -#line 19 "include/beman/execution/detail/set_value.hpp" -export /* --------- */ struct set_value_t { - template - auto operator()(Receiver&, Args&&...) const - -> void = BEMAN_EXECUTION_DELETE("set_value requires the receiver to be passed as non-const rvalue"); - template - auto operator()(const Receiver&&, Args&&...) const - -> void = BEMAN_EXECUTION_DELETE("set_value requires the receiver to be passed as non-const rvalue"); - template - auto operator()(Receiver&&, Args&&...) const -> void - requires(not requires(Receiver&& receiver, Args&&... args) { - ::std::forward(receiver).set_value(::std::forward(args)...); - }) - = BEMAN_EXECUTION_DELETE("set_value requires a suitable member overload on the receiver"); - template - requires(not noexcept(::std::declval().set_value(::std::declval()...))) - auto operator()(Receiver&&, Args&&...) const - -> void = BEMAN_EXECUTION_DELETE("the call to receiver.set_value(args...) has to be noexcept"); - - template - auto operator()(Receiver&& receiver, Args&&... args) const noexcept -> void { - ::std::forward(receiver).set_value(::std::forward(args)...); - } -}; - -#line 47 "include/beman/execution/detail/set_value.hpp" -export /* --------- */ inline constexpr set_value_t set_value{}; -} // namespace beman::execution - -#line 14 "include/beman/execution/detail/set_error.hpp" -namespace beman::execution { - -#line 19 "include/beman/execution/detail/set_error.hpp" -export /* --------- */ struct set_error_t { - template - auto operator()(Receiver&, Error&&) const - -> void = BEMAN_EXECUTION_DELETE("set_error requires the receiver to be passed as non-const rvalue"); - template - auto operator()(const Receiver&&, Error&&) const - -> void = BEMAN_EXECUTION_DELETE("set_error requires the receiver to be passed as non-const rvalue"); - template - auto operator()(Receiver&&, Error&&) const -> void - requires(not requires(Receiver&& receiver, Error&& error) { - ::std::forward(receiver).set_error(::std::forward(error)); - }) - = BEMAN_EXECUTION_DELETE("set_error requires a suitable member overload on the receiver"); - template - requires(not noexcept(::std::declval().set_error(::std::declval()))) - auto operator()(Receiver&&, Error&&) const - -> void = BEMAN_EXECUTION_DELETE("the call to receiver.set_error(error) has to be noexcept"); - - // NOLINTBEGIN(misc-no-recursion) - template - auto operator()(Receiver&& receiver, Error&& error) const noexcept -> void { - ::std::forward(receiver).set_error(::std::forward(error)); - } - // NOLINTEND(misc-no-recursion) -}; - -#line 49 "include/beman/execution/detail/set_error.hpp" -export /* --------- */ inline constexpr set_error_t set_error{}; -} // namespace beman::execution - -#line 14 "include/beman/execution/detail/set_stopped.hpp" -namespace beman::execution { - -#line 19 "include/beman/execution/detail/set_stopped.hpp" -export /* --------- */ struct set_stopped_t { - template - auto operator()(Receiver&) const - -> void = BEMAN_EXECUTION_DELETE("set_stopped requires the receiver to be passed as non-const rvalue"); - template - auto operator()(const Receiver&&) const - -> void = BEMAN_EXECUTION_DELETE("set_stopped requires the receiver to be passed as non-const rvalue"); - template - auto operator()(Receiver&&) const -> void - requires(not requires(Receiver&& receiver) { ::std::forward(receiver).set_stopped(); }) - = BEMAN_EXECUTION_DELETE("set_stopped requires a suitable member overload on the receiver"); - template - requires(not noexcept(::std::declval().set_stopped())) - auto operator()(Receiver&&) const - -> void = BEMAN_EXECUTION_DELETE("the call to receiver.set_stopped() has to be noexcept"); - - template - auto operator()(Receiver&& receiver) const noexcept -> void { - ::std::forward(receiver).set_stopped(); - } -}; - -#line 45 "include/beman/execution/detail/set_stopped.hpp" -export /* --------- */ inline constexpr set_stopped_t set_stopped{}; -} // namespace beman::execution - -#line 13 "include/beman/execution/detail/start.hpp" -namespace beman::execution { -export /* --------- */ struct start_t { - template - auto operator()(State&&) const -> void = BEMAN_EXECUTION_DELETE("start(obj) requires an lvalue argument"); - template - requires(not requires(State& state) { state.start(); }) - auto operator()(State&) const -> void = BEMAN_EXECUTION_DELETE("state needs to have a start() member"); - template - requires(not requires(const State& state) { state.start(); }) - auto operator()(const State&) const -> void = BEMAN_EXECUTION_DELETE("state needs to have a start() member"); - - template - requires(not requires(State& state) { - { state.start() } noexcept; - }) - auto operator()(State&) const -> void = BEMAN_EXECUTION_DELETE("state start() member has to be noexcept"); - template - requires(not requires(const State& state) { - { state.start() } noexcept; - }) - auto operator()(const State&) const -> void = BEMAN_EXECUTION_DELETE("state start() member has to be noexcept"); - - template - auto operator()(const State& state) const noexcept -> void { - state.start(); - } - // NOLINTBEGIN(misc-no-recursion) - template - auto operator()(State& state) const noexcept -> void { - state.start(); - } - // NOLINTEND(misc-no-recursion) -}; - -export /* --------- */ inline constexpr start_t start{}; -} // namespace beman::execution - -#line 11 "include/beman/execution/detail/non_assignable.hpp" -namespace beman::execution::detail { -struct non_assignable; -} -#line 17 "include/beman/execution/detail/non_assignable.hpp" -struct beman::execution::detail::non_assignable { - non_assignable() = default; - non_assignable(non_assignable&&) = default; - non_assignable(const non_assignable&) = default; - auto operator=(non_assignable&&) -> non_assignable& = delete; - auto operator=(const non_assignable&) -> non_assignable& = delete; -}; - -#line 13 "include/beman/execution/detail/simple_allocator.hpp" -namespace beman::execution::detail { -export /* --------- */ template -concept simple_allocator = - requires(::std::remove_cvref_t alloc, ::std::size_t n) { - { *alloc.allocate(n) } -> ::std::same_as::value_type&>; - alloc.deallocate(alloc.allocate(n), n); - } && ::std::copy_constructible<::std::remove_cvref_t> && - ::std::equality_comparable<::std::remove_cvref_t>; -} // namespace beman::execution::detail - -#line 11 "include/beman/execution/detail/never_stop_token.hpp" -namespace beman::execution { -export /* --------- */ class never_stop_token; -} -#line 17 "include/beman/execution/detail/never_stop_token.hpp" -class beman::execution::never_stop_token { - struct private_callback_type { - explicit private_callback_type(never_stop_token, auto&&) noexcept {} - }; - - public: - template - using callback_type = private_callback_type; - - static constexpr auto stop_requested() noexcept -> bool { return {}; } - static constexpr auto stop_possible() noexcept -> bool { return {}; } - auto operator==(const never_stop_token&) const -> bool = default; -}; - -#line 12 "include/beman/execution/detail/decayed_same_as.hpp" -namespace beman::execution::detail { - -#line 19 "include/beman/execution/detail/decayed_same_as.hpp" -template -concept decayed_same_as = ::std::same_as<::std::remove_cvref_t, ::std::remove_cvref_t>; -} // namespace beman::execution::detail - -#line 12 "include/beman/execution/detail/callable.hpp" -namespace beman::execution::detail { - -#line 19 "include/beman/execution/detail/callable.hpp" -template -concept callable = requires(Fun&& fun, Args&&... args) { ::std::forward(fun)(::std::forward(args)...); }; -} // namespace beman::execution::detail - -#line 15 "include/beman/execution/detail/forward_like.hpp" -namespace beman::execution::detail { -template -struct forward_like_helper; - -template -struct forward_like_helper { - template - static auto forward(U&& u) -> ::std::remove_reference_t&& { - return ::std::move(u); // NOLINT(bugprone-move-forwarding-reference) - } -}; -template -struct forward_like_helper { - template - static auto forward(U&& u) -> ::std::remove_cvref_t&& { - return ::std::move(u); // NOLINT(bugprone-move-forwarding-reference) - } -}; -template -struct forward_like_helper { - template - static auto forward(U&& u) -> ::std::remove_cvref_t& { - return ::std::forward(u); - } -}; -template -struct forward_like_helper { - template - static auto forward(U&& u) -> const ::std::remove_cvref_t&& { - return ::std::move(u); // NOLINT(bugprone-move-forwarding-reference) - } -}; -template -struct forward_like_helper { - template - static auto forward(U&& u) -> const ::std::remove_cvref_t& { - return ::std::forward(u); - } -}; - -#line 57 "include/beman/execution/detail/forward_like.hpp" -template -auto own_forward_like(U&& u) noexcept -> decltype(auto) { - return ::beman::execution::detail::forward_like_helper::forward(::std::forward(u)); -} -#line 67 "include/beman/execution/detail/forward_like.hpp" -template -auto forward_like(U&& u) noexcept -> decltype(auto) { -#if 202207 <= disabled__cpp_lib_forward_like - return ::std::forward_like(::std::forward(u)); -#else - return ::beman::execution::detail::forward_like_helper::forward(::std::forward(u)); -#endif -} -#line 76 "include/beman/execution/detail/forward_like.hpp" -} // namespace beman::execution::detail - -#line 13 "include/beman/execution/detail/join_env.hpp" -namespace beman::execution::detail { -template -class join_env { - private: - Env1 env1; - Env2 env2; - - public: - template - join_env(E1&& e1, E2&& e2) : env1(::std::forward(e1)), env2(::std::forward(e2)) {} - - template - requires requires(Env1&, const Query& query, Args&&... args) { - env1.query(query, ::std::forward(args)...); - } - auto query(const Query& query, Args&&... args) noexcept -> decltype(auto) { - return this->env1.query(query, ::std::forward(args)...); - } - template - requires( - not requires(Env1&, const Query& query, Args&&... args) { - env1.query(query, ::std::forward(args)...); - } && - requires(Env2& e2, const Query& query, Args&&... args) { e2.query(query, ::std::forward(args)...); }) - auto query(const Query& query, Args&&... args) noexcept -> decltype(auto) { - return this->env2.query(query, ::std::forward(args)...); - } - template - requires requires(const Env1& e1, const Query& query, Args&&... args) { - { e1.query(query, ::std::forward(args)...) } noexcept; - } - auto query(const Query& query, Args&&... args) const noexcept -> decltype(auto) { - return this->env1.query(query, ::std::forward(args)...); - } - template - requires( - not requires(const Env1& e1, const Query& query, Args&&... args) { - { e1.query(query, ::std::forward(args)...) } noexcept; - } && - requires(const Env2& e2, const Query& query, Args&&... args) { - { e2.query(query, ::std::forward(args)...) } noexcept; - }) - auto query(const Query& query, Args&&... args) const noexcept -> decltype(auto) { - return this->env2.query(query, ::std::forward(args)...); - } -}; - -template -join_env(Env1&&, Env2&&) -> join_env<::std::remove_cvref_t, ::std::remove_cvref_t>; -} // namespace beman::execution::detail - -#line 15 "include/beman/execution/detail/product_type.hpp" -namespace beman::execution::detail { - -template <::std::size_t I, typename T> -struct product_type_element { - T value; - auto operator==(const product_type_element&) const -> bool = default; -}; - -template -struct product_type_base; - -template <::std::size_t... I, typename... T> -struct product_type_base<::std::index_sequence, T...> - : ::beman::execution::detail::product_type_element... { - static constexpr ::std::size_t size() { return sizeof...(T); } - static constexpr bool is_product_type{true}; - - template <::std::size_t J, typename S> - static auto element_get(::beman::execution::detail::product_type_element& self) noexcept -> S& { - return self.value; - } - template <::std::size_t J, typename S> - static auto element_get(::beman::execution::detail::product_type_element&& self) noexcept -> S&& { - return ::std::move(self.value); - } - template <::std::size_t J, typename S> - static auto element_get(const ::beman::execution::detail::product_type_element& self) noexcept -> const S& { - return self.value; - } -#line 45 "include/beman/execution/detail/product_type.hpp" - template <::std::size_t J> - auto get() & -> decltype(auto) { - return this->element_get(*this); - } - template <::std::size_t J> - auto get() && -> decltype(auto) { - return this->element_get(::std::move(*this)); - } - template <::std::size_t J> - auto get() const& -> decltype(auto) { - return this->element_get(*this); - } -#line 58 "include/beman/execution/detail/product_type.hpp" - template <::std::size_t J, typename Allocator, typename Self> - static auto make_element(Allocator&& alloc, Self&& self) -> decltype(auto) { - using type = ::std::remove_cvref_t(std::forward(self)))>; - if constexpr (::std::uses_allocator_v) - return ::std::make_obj_using_allocator(alloc, - product_type_base::element_get(std::forward(self))); - else - return product_type_base::element_get(std::forward(self)); - } -#line 68 "include/beman/execution/detail/product_type.hpp" - auto operator==(const product_type_base&) const -> bool = default; -}; - -template -concept is_product_type_c = requires(const T& t) { T::is_product_type; }; - -template -struct product_type : ::beman::execution::detail::product_type_base<::std::index_sequence_for, T...> { - template - static auto make_from(Allocator&& allocator, Product&& product, std::index_sequence) -> product_type { - return {product_type::template make_element(allocator, ::std::forward(product))...}; - } -#line 81 "include/beman/execution/detail/product_type.hpp" - template - static auto make_from(Allocator&& allocator, Product&& product) -> product_type { - return product_type::make_from( - ::std::forward(allocator), ::std::forward(product), ::std::index_sequence_for{}); - } -#line 87 "include/beman/execution/detail/product_type.hpp" - template - constexpr auto apply_elements(::std::index_sequence, Fun&& fun) const -> decltype(auto) { - return ::std::forward(fun)(this->template get()...); - } - template - constexpr auto apply(Fun&& fun) const -> decltype(auto) { - return apply_elements(::std::index_sequence_for{}, ::std::forward(fun)); - } - template - constexpr auto apply_elements(::std::index_sequence, Fun&& fun) -> decltype(auto) { - - return ::std::forward(fun)(std::move(this->template get())...); - } - template - constexpr auto apply(Fun&& fun) -> decltype(auto) { - return apply_elements(::std::index_sequence_for{}, ::std::forward(fun)); - } -}; -template -product_type(T&&...) -> product_type<::std::decay_t...>; - -template -constexpr auto is_product_type(const T&) -> ::std::false_type { - return {}; -} -template -constexpr auto is_product_type(const ::beman::execution::detail::product_type&) -> ::std::true_type { - return {}; -} -#line 117 "include/beman/execution/detail/product_type.hpp" -template <::std::size_t Start, typename Fun, typename Tuple, ::std::size_t... I> -constexpr auto sub_apply_helper(Fun&& fun, Tuple&& tuple, ::std::index_sequence) -> decltype(auto) { - // NOLINTNEXTLINE(bugprone-use-after-move,hicpp-invalid-access-moved) - return ::std::forward(fun)(::std::forward(tuple).template get()...); -} -#line 123 "include/beman/execution/detail/product_type.hpp" -template <::std::size_t Start, typename Fun, typename Tuple> -constexpr auto sub_apply(Fun&& fun, Tuple&& tuple) -> decltype(auto) { - constexpr ::std::size_t TSize{::std::tuple_size_v<::std::remove_cvref_t>}; - static_assert(Start <= TSize); - return sub_apply_helper( - ::std::forward(fun), ::std::forward(tuple), ::std::make_index_sequence()); -} -#line 131 "include/beman/execution/detail/product_type.hpp" -} // namespace beman::execution::detail - -namespace std { -template - requires ::beman::execution::detail::is_product_type_c -struct tuple_size : ::std::integral_constant {}; - -template <::std::size_t I, typename T> - requires ::beman::execution::detail::is_product_type_c -struct tuple_element { - using type = ::std::decay_t().template get())>; -}; -} // namespace std - -#line 12 "include/beman/execution/detail/query_with_default.hpp" -namespace beman::execution::detail { -template - requires requires(const Tag& tag, const Env& env) { tag(env); } -constexpr auto query_with_default(Tag, const Env& env, Value&&) noexcept(noexcept(Tag()(env))) -> decltype(auto) { - return Tag()(env); -} -#line 19 "include/beman/execution/detail/query_with_default.hpp" -template -constexpr auto -query_with_default(Tag, const Env&, Value&& value) noexcept(noexcept(static_cast(std::forward(value)))) - -> decltype(auto) { - return static_cast(std::forward(value)); -} -} // namespace beman::execution::detail - -#line 13 "include/beman/execution/detail/child_type.hpp" -namespace beman::execution::detail { - -#line 19 "include/beman/execution/detail/child_type.hpp" -template -using child_type = decltype(::std::declval().template get()); -} // namespace beman::execution::detail - -#line 13 "include/beman/execution/detail/decayed_tuple.hpp" -namespace beman::execution::detail { - -#line 19 "include/beman/execution/detail/decayed_tuple.hpp" -template -using decayed_tuple = ::std::tuple<::std::decay_t...>; -} // namespace beman::execution::detail - -#line 13 "include/beman/execution/detail/make_env.hpp" -namespace beman::execution::detail { -export /* --------- */ template -class make_env { - private: - Value value; - - public: - template - make_env(const Query&, V&& v) : value(::std::forward(v)) {} - constexpr auto query(const Query&) const noexcept -> const Value& { return this->value; } - constexpr auto query(const Query&) noexcept -> Value& { return this->value; } -}; -template -make_env(Query&&, Value&& value) -> make_env<::std::remove_cvref_t, ::std::remove_cvref_t>; -} // namespace beman::execution::detail - -#line 11 "include/beman/execution/detail/meta_prepend.hpp" -namespace beman::execution::detail::meta::detail { -template -struct prepend; - -template