Skip to content
This repository was archived by the owner on Sep 13, 2026. It is now read-only.

Commit 43ab22f

Browse files
authored
Fix various detail (#101)
* fix header names * fix compiler explorer link to point to an [eventually] working example * fixed some examples * clang-format
1 parent be657d7 commit 43ab22f

7 files changed

Lines changed: 35 additions & 25 deletions

File tree

‎examples/CMakeLists.txt‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ if(NOT MSVC)
4545
issue_affine
4646
cppnow_affinity
4747
cppnow_basic
48-
# FIXME: cppnow_query
48+
cppnow_query
4949
cppnow_result_types
5050
cppnow_return
51-
# FIXME: cppnow_stop_token
51+
cppnow_stop_token
5252
cppnow_with_error
5353
co_await_result
5454
co_await_task
@@ -57,9 +57,9 @@ if(NOT MSVC)
5757
friendly
5858
hello
5959
issue_frame_allocator
60-
# FIXME: query
60+
query
6161
result_example
62-
# FIXME: stop
62+
stop
6363
)
6464
endif()
6565

‎examples/cppnow_query.cpp‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
#include <beman/execution.hpp>
66
#include <iostream>
77

8-
namespace ex = beman::execution;
9-
namespace exd = beman::execution::detail;
8+
namespace ex = beman::execution;
109

1110
// ----------------------------------------------------------------------------
1211

@@ -61,6 +60,6 @@ ex::task<void, fancy> with_fancy_env() {
6160
} // namespace
6261

6362
int main() {
64-
ex::sync_wait(exd::write_env(with_env(), exd::make_env(get_value, 17)));
65-
ex::sync_wait(exd::write_env(with_fancy_env(), exd::make_env(get_value, 17)));
63+
ex::sync_wait(ex::write_env(with_env(), ex::detail::make_env(get_value, 17)));
64+
ex::sync_wait(ex::write_env(with_fancy_env(), ex::detail::make_env(get_value, 17)));
6665
}

‎examples/cppnow_stop_token.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ int main() {
2929

3030
ex::inplace_stop_source source;
3131
std::thread thread([&] {
32-
ex::sync_wait(ex::detail::write_env(stopping(), ex::detail::make_env(ex::get_stop_token, source.get_token())));
32+
ex::sync_wait(ex::write_env(stopping(), ex::detail::make_env(ex::get_stop_token, source.get_token())));
3333
});
3434

3535
std::this_thread::sleep_for(100ms);

‎examples/into_optional.cpp‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ template <typename... S>
1515
struct multi_sender {
1616
using sender_concept = ex::sender_tag;
1717
using completion_signatures = ex::completion_signatures<S...>;
18+
template <typename...>
19+
static consteval auto get_completion_signatures() {
20+
return completion_signatures{};
21+
}
1822

1923
template <typename Receiver>
2024
auto connect(Receiver&& receiver) const {
@@ -69,8 +73,12 @@ auto my_into_optional(S&& s) {
6973
int main() {
7074
queue<double> que;
7175
ex::sync_wait([](auto& q) -> ex::task<> {
72-
// auto x = co_await ex::just(true) | into_optional;
73-
[[maybe_unused]] std::optional x = co_await (q.async_pop() | ex::into_optional);
74-
[[maybe_unused]] std::optional y = co_await ex::into_optional(q.async_pop());
76+
static_assert(
77+
std::same_as<void,
78+
decltype(ex::get_completion_signatures<decltype(ex::just(true) | ex::into_optional)>())>);
79+
// auto x = co_await (ex::just(true) | ex::into_optional);
80+
// [[maybe_unused]] std::optional x = co_await (q.async_pop() | ex::into_optional);
81+
// [[maybe_unused]] std::optional y = co_await ex::into_optional(q.async_pop());
82+
co_return;
7583
}(que));
7684
}

‎examples/query.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ struct context {
4949
};
5050

5151
int main() {
52-
ex::sync_wait(ex::detail::write_env(
52+
ex::sync_wait(ex::write_env(
5353
[]() -> ex::task<void, simple_context> {
5454
auto value(co_await ex::read_env(get_value));
5555
std::cout << "value=" << value << "\n";
5656
}(),
5757
ex::detail::make_env(get_value, 42)));
58-
ex::sync_wait(ex::detail::write_env(
58+
ex::sync_wait(ex::write_env(
5959
[]() -> ex::task<void, context> {
6060
auto value(co_await ex::read_env(get_value));
6161
std::cout << "value=" << value << "\n";

‎examples/stop.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ int main() {
3333
};
3434
};
3535

36-
auto [result] = ex::sync_wait(ex::detail::write_env(
36+
auto [result] = ex::sync_wait(ex::write_env(
3737
[]() -> ex::task<std::uint64_t, context> {
3838
auto token(co_await ex::read_env(ex::get_stop_token));
3939
std::uint64_t count{};

‎include/beman/task/detail/into_optional.hpp‎

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ namespace beman::task::detail {
1515
inline constexpr struct into_optional_t : beman::execution::sender_adaptor_closure<into_optional_t> {
1616
template <::beman::execution::sender Upstream>
1717
struct sender {
18-
using upstream_t = std::remove_cvref_t<Upstream>;
1918
using sender_concept = ::beman::execution::sender_tag;
19+
using upstream_t = std::remove_cvref_t<Upstream>;
2020
upstream_t upstream;
2121

2222
template <typename...>
@@ -48,22 +48,25 @@ inline constexpr struct into_optional_t : beman::execution::sender_adaptor_closu
4848
}
4949

5050
template <typename Env>
51-
static auto get_type(Env&&) {
51+
static consteval auto get_type() {
5252
return find_type(
5353
::beman::execution::value_types_of_t<Upstream, std::remove_cvref_t<Env>, type_list, type_list>());
5454
}
5555

56-
template <typename... E, typename... S>
57-
constexpr auto make_signatures(auto&& env, type_list<E...>, type_list<S...>) const {
56+
template <typename Env, typename... E, typename... S>
57+
static consteval auto make_signatures(type_list<E...>, type_list<S...>) {
5858
return ::beman::execution::completion_signatures<::beman::execution::set_value_t(
59-
decltype(this->get_type(env))),
59+
decltype(get_type<Env>())),
6060
::beman::execution::set_error_t(E)...,
6161
S...>();
6262
}
63-
template <typename Env>
64-
auto get_completion_signatures(Env&& env) const {
65-
return make_signatures(
66-
env,
63+
template <typename, typename Env>
64+
static consteval auto get_completion_signatures() {
65+
static_assert(::beman::execution::sender<Upstream>);
66+
static_assert(::beman::execution::sender_in<Upstream>);
67+
static_assert(::beman::execution::sender_in<Upstream, Env>);
68+
return make_signatures<Env>(
69+
::beman::execution::value_types_of_t<Upstream, std::remove_cvref_t<Env>, type_list>{},
6770
::beman::execution::error_types_of_t<Upstream, std::remove_cvref_t<Env>, type_list>{},
6871
std::conditional_t<::beman::execution::sends_stopped<Upstream, std::remove_cvref_t<Env>>,
6972
type_list<::beman::execution::set_stopped_t()>,
@@ -73,7 +76,7 @@ inline constexpr struct into_optional_t : beman::execution::sender_adaptor_closu
7376
struct make_object {
7477
template <typename... A>
7578
auto operator()(A&&... a) const
76-
-> decltype(get_type(::beman::execution::get_env(std::declval<Receiver>()))) {
79+
-> decltype(get_type<decltype(::beman::execution::get_env(std::declval<Receiver>()))>()) {
7780
if constexpr (sizeof...(A) == 0u)
7881
return {};
7982
else

0 commit comments

Comments
 (0)