Skip to content

Commit 8002dc4

Browse files
committed
Add sender_to concept
1 parent 0da102d commit 8002dc4

File tree

6 files changed

+71
-0
lines changed

6 files changed

+71
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// include/beman/execution/detail/sender_to.hpp -*-C++-*-
2+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3+
4+
#ifndef INCLUDED_BEMAN_EXECUTION_DETAIL_SENDER_TO
5+
#define INCLUDED_BEMAN_EXECUTION_DETAIL_SENDER_TO
6+
7+
#ifdef BEMAN_HAS_IMPORT_STD
8+
import std;
9+
#else
10+
#include <utility>
11+
#endif
12+
#include <beman/execution/detail/common.hpp>
13+
#ifdef BEMAN_HAS_MODULES
14+
import beman.execution.detail.completion_signatures_of_t;
15+
import beman.execution.detail.connect;
16+
import beman.execution.detail.env_of_t;
17+
import beman.execution.detail.receiver_of;
18+
import beman.execution.detail.sender_in;
19+
#else
20+
#include <beman/execution/detail/completion_signatures_of_t.hpp>
21+
#include <beman/execution/detail/connect.hpp>
22+
#include <beman/execution/detail/env_of_t.hpp>
23+
#include <beman/execution/detail/receiver_of.hpp>
24+
#include <beman/execution/detail/sender_in.hpp>
25+
#endif
26+
27+
// ----------------------------------------------------------------------------
28+
29+
namespace beman::execution {
30+
template <typename Sender, typename Receiver>
31+
concept sender_to =
32+
::beman::execution::sender_in<Sender, ::beman::execution::env_of_t<Receiver>> &&
33+
::beman::execution::receiver_of<
34+
Receiver,
35+
::beman::execution::completion_signatures_of_t<Sender, ::beman::execution::env_of_t<Receiver>>> &&
36+
requires(Sender&& sndr, Receiver&& rcvr) {
37+
::beman::execution::connect(::std::forward<Sender>(sndr), ::std::forward<Receiver>(rcvr));
38+
};
39+
} // namespace beman::execution
40+
41+
// ----------------------------------------------------------------------------
42+
43+
#endif // INCLUDED_BEMAN_EXECUTION_DETAIL_SENDER_TO

include/beman/execution/execution.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ import beman.execution.detail.write_env;
8787
#include <beman/execution/detail/get_env.hpp>
8888
#include <beman/execution/detail/get_scheduler.hpp>
8989
#include <beman/execution/detail/get_stop_token.hpp>
90+
#include <beman/execution/detail/inline_scheduler.hpp>
9091
#include <beman/execution/detail/into_variant.hpp>
9192
#include <beman/execution/detail/just.hpp>
9293
#include <beman/execution/detail/let.hpp>
@@ -102,6 +103,7 @@ import beman.execution.detail.write_env;
102103
#include <beman/execution/detail/scope_token.hpp>
103104
#include <beman/execution/detail/sender_adaptor_closure.hpp>
104105
#include <beman/execution/detail/sender_in.hpp>
106+
#include <beman/execution/detail/sender_to.hpp>
105107
#include <beman/execution/detail/sender.hpp>
106108
#include <beman/execution/detail/set_error.hpp>
107109
#include <beman/execution/detail/set_stopped.hpp>

src/beman/execution/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ target_sources(
156156
${PROJECT_SOURCE_DIR}/include/beman/execution/detail/sender_for.hpp
157157
${PROJECT_SOURCE_DIR}/include/beman/execution/detail/sender_has_affine_on.hpp
158158
${PROJECT_SOURCE_DIR}/include/beman/execution/detail/sender_in.hpp
159+
${PROJECT_SOURCE_DIR}/include/beman/execution/detail/sender_to.hpp
159160
${PROJECT_SOURCE_DIR}/include/beman/execution/detail/sends_stopped.hpp
160161
${PROJECT_SOURCE_DIR}/include/beman/execution/detail/set_error.hpp
161162
${PROJECT_SOURCE_DIR}/include/beman/execution/detail/set_stopped.hpp
@@ -345,6 +346,7 @@ if(BEMAN_USE_MODULES)
345346
sender_has_affine_on.cppm
346347
sender_in.cppm
347348
sender.cppm
349+
sender_to.cppm
348350
sends_stopped.cppm
349351
set_error.cppm
350352
set_stopped.cppm

src/beman/execution/execution.cppm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ export import beman.execution.detail.receiver_of;
9393
export import beman.execution.detail.sender;
9494
export import beman.execution.detail.sender_in;
9595
//-dk:TODO export using ::beman::execution::sender_to;
96+
export import beman.execution.detail.sender_to;
9697

9798
export import beman.execution.detail.sends_stopped;
9899

src/beman/execution/sender_to.cppm

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module;
2+
// src/beman/execution/sender_to.cppm -*-C++-*-
3+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+
5+
#include <beman/execution/detail/sender_to.hpp>
6+
7+
export module beman.execution.detail.sender_to;
8+
9+
namespace beman::execution {
10+
export using beman::execution::sender_to;
11+
} // namespace beman::execution

tests/beman/execution/exec-snd-concepts.test.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,17 @@ auto test_sender_for() -> void {
173173
static_assert(test_std::sender<std_sender>);
174174
static_assert(not test_detail::sender_for<std_sender, tag_t>);
175175
}
176+
177+
auto test_sender_to() -> void {
178+
struct int_receiver {
179+
using receiver_concept = test_std::receiver_t;
180+
static auto set_value(int) noexcept -> void {}
181+
};
182+
183+
static_assert(test_std::sender_to<decltype(test_std::just(1)), int_receiver>);
184+
static_assert(not test_std::sender_to<decltype(test_std::just()), int_receiver>);
185+
}
186+
176187
} // namespace
177188

178189
TEST(exec_snd_concepts) {
@@ -183,4 +194,5 @@ TEST(exec_snd_concepts) {
183194
test_sender_in();
184195
test_tag_of_t();
185196
test_sender_for();
197+
test_sender_to();
186198
}

0 commit comments

Comments
 (0)