diff --git a/README.md b/README.md index 97f58a0e..b23dfb32 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ e.g.: | Library | Linux | MacOS | Windows | | ------- | ----- | ----- | ------- | -| build | ![Linux build status](https://github.com/dietmarkuehl/beman-execution/actions/workflows/linux.yml/badge.svg) | ![MacOS build status](https://github.com/dietmarkuehl/beman-execution/actions/workflows/macos.yml/badge.svg) | ![Window build status](https://github.com/dietmarkuehl/beman-execution/actions/workflows/windows.yml/badge.svg) | +| build | ![Linux build status](https://github.com/beman-project/Execution26/actions/workflows/linux.yml/badge.svg) | ![MacOS build status](https://github.com/beman-project/Execution26/actions/workflows/macos.yml/badge.svg) | ![Window build status](https://github.com/beman-project/Execution26/actions/workflows/windows.yml/badge.svg) | You can just use `make` in the current directory. It will invoke `cmake`, build the code, and run tests. To have more control over the build-process diff --git a/docs/TODO.json b/docs/TODO.json index 0fee7ca3..e87ba8b1 100644 --- a/docs/TODO.json +++ b/docs/TODO.json @@ -4,6 +4,7 @@ "execution.queries": { "code":true, "test":true, "doc":true, "comment":"empty" }, "execution.queryable": { "code":true, "test":true, "doc":true, "comment":"empty" }, "execution.queryable.general]": { "code":true, "test":true, "doc":false, "comment":"nothing testable" }, + "execution.forwarding_query": { "code":true, "test":true, "doc":false }, "execution.queryable.concepts": { "code":true, "test":true, "doc":false }, "execution.receivers": { "code":true, "test":true, "doc":true, "comment":"empty" }, "execution.senders": { "code":true, "test":true, "doc":true, "comment":"empty" }, diff --git a/docs/TODO.md b/docs/TODO.md index 441c632a..12bc6327 100644 --- a/docs/TODO.md +++ b/docs/TODO.md @@ -49,7 +49,7 @@ | [[execution-async.ops](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2300r10.html#execution-async.ops)] | 🔴 | 🔴 | 🔴 | | | [[execution.syn](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2300r10.html#execution.syn)] | 🔴 | 🔴 | 🔴 | | | [[execution.queries](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2300r10.html#execution.queries)] | ✅ | ✅ | ✅ | empty | -| [[execution.forwarding_query](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2300r10.html#execution.forwarding_query)] | 🔴 | 🔴 | 🔴 | | +| [[execution.forwarding_query](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2300r10.html#execution.forwarding_query)] | ✅ | ✅ | 🔴 | | | [[execution.get_allocator](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2300r10.html#execution.get_allocator)] | 🔴 | 🔴 | 🔴 | | | [[execution.get_stop_token](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2300r10.html#execution.get_stop_token)] | 🔴 | 🔴 | 🔴 | | | [[execution.environment.get_env](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2300r10.html#execution.environment.get_env)] | 🔴 | 🔴 | 🔴 | | @@ -64,7 +64,7 @@ | [[execution.receivers.set_value](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2300r10.html#execution.receivers.set_value)] | ✅ | ✅ | 🔴 | | | [[execution.receivers.set_error](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2300r10.html#execution.receivers.set_error)] | ✅ | ✅ | 🔴 | | | [[execution.receivers.set_stopped](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2300r10.html#execution.receivers.set_stopped)] | ✅ | ✅ | 🔴 | | -| [[execution.opstate](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2300r10.html#execution.opstate)] | 🔴 | 🔴 | 🔴 | | +| [[execution.opstate](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2300r10.html#execution.opstate)] | ✅ | ✅ | 🔴 | | | [[execution.opstate.start](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2300r10.html#execution.opstate.start)] | ✅ | ✅ | 🔴 | | | [[execution.senders](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2300r10.html#execution.senders)] | ✅ | ✅ | ✅ | empty | | [[execution.senders.general](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2300r10.html#execution.senders.general)] | 🔴 | 🔴 | 🔴 | | diff --git a/docs/questions.md b/docs/questions.md index 19c447e3..f52bab6b 100644 --- a/docs/questions.md +++ b/docs/questions.md @@ -12,3 +12,6 @@ likely observable. - [exec.general] use "Mandates: err != exception_ptr() is true." However, the condition can only be determined at run-time => The "Mandates" should be "Precondition". +- [exec.fwd.env] states "Mandates: ... is a core constant expression if + `q` is a core constant expression": I don't know how to possibly + implement that. \ No newline at end of file diff --git a/include/Beman/Execution26/detail/forwarding_query.hpp b/include/Beman/Execution26/detail/forwarding_query.hpp new file mode 100644 index 00000000..af033545 --- /dev/null +++ b/include/Beman/Execution26/detail/forwarding_query.hpp @@ -0,0 +1,37 @@ +// include/Beman/Execution26/detail/forwarding_query.hpp -*-C++-*- +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#ifndef INCLUDED_BEMAN_EXECUTION26_DETAIL_FORWARDING_QUERY +#define INCLUDED_BEMAN_EXECUTION26_DETAIL_FORWARDING_QUERY + +#include +#include + +// ---------------------------------------------------------------------------- + +namespace Beman::Execution26 +{ + struct forwarding_query_t + { + template + requires requires(Object&& object, forwarding_query_t const& 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; + } + }; + + inline constexpr forwarding_query_t forwarding_query{}; +} + +// ---------------------------------------------------------------------------- + +#endif diff --git a/src/Beman/Execution26/tests/CMakeLists.txt b/src/Beman/Execution26/tests/CMakeLists.txt index cdf3bfb7..aab0b0f7 100644 --- a/src/Beman/Execution26/tests/CMakeLists.txt +++ b/src/Beman/Execution26/tests/CMakeLists.txt @@ -2,6 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception list(APPEND execution_tests + exec-fwd-env.pass exec-opstate.pass exec-opstate-start.pass allocator-requirements-general.pass diff --git a/src/Beman/Execution26/tests/exec-fwd-env.pass.cpp b/src/Beman/Execution26/tests/exec-fwd-env.pass.cpp new file mode 100644 index 00000000..43a2a4f2 --- /dev/null +++ b/src/Beman/Execution26/tests/exec-fwd-env.pass.cpp @@ -0,0 +1,80 @@ +// src/Beman/Execution26/tests/exec-fwd-env.pass.cpp -*-C++-*- +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +#include +#include +#include + +// ---------------------------------------------------------------------------- + +namespace +{ + struct derived + : test_std::forwarding_query_t + { + }; + + template + struct static_query + { + constexpr auto query(test_std::forwarding_query_t) noexcept(Noexcept) -> Result + { + return Value; + } + }; + + struct rvalue_query + { + constexpr auto query(test_std::forwarding_query_t) && noexcept -> bool + { + return true; + } + }; + + struct const_query + { + constexpr auto query(test_std::forwarding_query_t&&) noexcept -> bool = delete; + constexpr auto query(test_std::forwarding_query_t&) noexcept -> bool = delete; + constexpr auto query(test_std::forwarding_query_t const&) noexcept -> bool + { + return true; + } + }; + + struct dynamic_query + { + bool value{true}; + constexpr auto query(test_std::forwarding_query_t) && noexcept -> bool + { + return value; + } + }; +} + +auto main(int ac, char*[]) -> int +{ + static_assert(std::same_as); + + static_assert(not test_std::forwarding_query(0)); + static_assert(test_std::forwarding_query(derived())); + static_assert(test_std::forwarding_query(static_query<>())); + static_assert(not test_std::forwarding_query(static_query())); + static_assert(not test_std::forwarding_query(static_query())); + static_assert(not test_std::forwarding_query(static_query())); + + static_assert(test_std::forwarding_query(rvalue_query())); + rvalue_query rq{}; + static_assert(not test_std::forwarding_query(rq)); + rvalue_query crq{}; + static_assert(not test_std::forwarding_query(crq)); + + static_assert(test_std::forwarding_query(const_query())); + + static_assert(test_std::forwarding_query(dynamic_query())); + static_assert(test_std::forwarding_query(dynamic_query{true})); + static_assert(not test_std::forwarding_query(dynamic_query{false})); + assert(test_std::forwarding_query(dynamic_query{ac == 1})); + assert(not test_std::forwarding_query(dynamic_query{ac != 1})); +} \ No newline at end of file