Skip to content

Commit cdcf463

Browse files
committed
added just* algorithms
1 parent 41df058 commit cdcf463

21 files changed

+318
-10
lines changed

docs/questions.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,6 @@ likely observable.
1919
is defined.
2020
- [exec.snd.concepts] "The type tag_of_t<Sndr> is +defined+ as follows:"
2121
- [exec.sched] uses `auto(get_completion_scheduler<set_value_t>(...))`
22-
which is OK for clang but doesn't seem to compile for g++ os MSVC.
22+
which is OK for clang but doesn't seem to compile for g++ os MSVC.
23+
- [exec.just] p2.1: movable-value<Ts> doesn't seems right: movable-value<decay_t<Ts>>
24+
- [exec.just] Otherwise after p2.3 is missing <ts...>

include/beman/execution26/detail/basic_operation.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <beman/execution26/detail/basic_state.hpp>
99
#include <beman/execution26/detail/state_type.hpp>
1010
#include <beman/execution26/detail/sender_decompose.hpp>
11+
#include <beman/execution26/detail/tag_of_t.hpp>
1112
#include <beman/execution26/detail/impls_for.hpp>
1213
#include <beman/execution26/detail/connect_all_result.hpp>
1314
#include <beman/execution26/detail/valid_specialization.hpp>

include/beman/execution26/detail/basic_receiver.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <beman/execution26/detail/impls_for.hpp>
1111
#include <beman/execution26/detail/receiver.hpp>
1212
#include <beman/execution26/detail/sender_decompose.hpp>
13+
#include <beman/execution26/detail/tag_of_t.hpp>
1314
#include <beman/execution26/detail/state_type.hpp>
1415
#include <beman/execution26/detail/valid_specialization.hpp>
1516
#include <utility>

include/beman/execution26/detail/basic_sender.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ namespace beman::execution26::detail
3333
}, data.children);
3434
}
3535

36+
template <typename Receiver>
37+
requires (not ::beman::execution26::receiver<Receiver>)
38+
auto connect(Receiver receiver)
39+
= BEMAN_EXECUTION26_DELETE("the passed receiver doesn't model receiver");
3640
#if __cpp_explicit_this_parameter < 202110L
3741
template <::beman::execution26::receiver Receiver>
3842
auto connect(Receiver receiver) &

include/beman/execution26/detail/basic_state.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <beman/execution26/detail/impls_for.hpp>
88
#include <beman/execution26/detail/sender_decompose.hpp>
9+
#include <beman/execution26/detail/tag_of_t.hpp>
910
#include <beman/execution26/detail/state_type.hpp>
1011
#include <utility>
1112

include/beman/execution26/detail/connect.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ namespace beman::execution26
3939
}
4040
else
4141
{
42-
static_assert(::std::same_as<int, Sender>,
43-
"result from transform_sender has no suitable connect()");
42+
enum bad_sender {};
43+
static_assert(::std::same_as<bad_sender, decltype(new_sender())>, "result from transform_sender has no suitable connect()");
4444
}
4545
}
4646
};

include/beman/execution26/detail/default_domain.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <beman/execution26/detail/queryable.hpp>
88
#include <beman/execution26/detail/sender.hpp>
99
#include <beman/execution26/detail/sender_decompose.hpp>
10+
#include <beman/execution26/detail/tag_of_t.hpp>
1011
#include <type_traits>
1112
#include <utility>
1213

include/beman/execution26/detail/env_type.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <beman/execution26/detail/call_result_t.hpp>
88
#include <beman/execution26/detail/impls_for.hpp>
99
#include <beman/execution26/detail/sender_decompose.hpp>
10+
#include <beman/execution26/detail/tag_of_t.hpp>
1011
#include <beman/execution26/detail/state_type.hpp>
1112

1213
// ----------------------------------------------------------------------------

include/beman/execution26/detail/get_domain_late.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <beman/execution26/detail/get_domain.hpp>
1111
#include <beman/execution26/detail/get_scheduler.hpp>
1212
#include <beman/execution26/detail/sender_decompose.hpp>
13+
#include <beman/execution26/detail/tag_of_t.hpp>
1314
#include <concepts>
1415

1516
// ----------------------------------------------------------------------------
+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
// include/beman/execution26/detail/just.hpp -*-C++-*-
2+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3+
4+
#ifndef INCLUDED_BEMAN_EXECUTION26_DETAIL_JUST
5+
#define INCLUDED_BEMAN_EXECUTION26_DETAIL_JUST
6+
7+
#include <beman/execution26/detail/set_error.hpp>
8+
#include <beman/execution26/detail/set_stopped.hpp>
9+
#include <beman/execution26/detail/set_value.hpp>
10+
#include <beman/execution26/detail/make_sender.hpp>
11+
#include <beman/execution26/detail/product_type.hpp>
12+
#include <beman/execution26/detail/completion_signatures_for.hpp>
13+
#include <beman/execution26/detail/impls_for.hpp>
14+
#include <beman/execution26/detail/decayed_typeof.hpp>
15+
#include <beman/execution26/detail/default_impls.hpp>
16+
#include <concepts>
17+
#include <utility>
18+
19+
// ----------------------------------------------------------------------------
20+
21+
namespace beman::execution26::detail
22+
{
23+
template <typename Completion, typename... T>
24+
concept just_size
25+
= (not ::std::same_as<Completion, ::beman::execution26::set_error_t>
26+
or 1u == sizeof...(T))
27+
&& (not ::std::same_as<Completion, ::beman::execution26::set_stopped_t>
28+
or 0u == sizeof...(T))
29+
;
30+
template <typename Completion>
31+
struct just_t
32+
{
33+
template <typename... T>
34+
requires ::beman::execution26::detail::just_size<Completion, T...>
35+
&& (::std::movable<::std::decay_t<T>> && ...)
36+
auto operator()(T&&... arg) const
37+
{
38+
return ::beman::execution26::detail::make_sender(
39+
*this,
40+
::beman::execution26::detail::product_type{::std::forward<T>(arg)...}
41+
);
42+
}
43+
};
44+
45+
template <typename Completion, typename... T, typename Env>
46+
struct completion_signatures_for_impl<
47+
::beman::execution26::detail::basic_sender<
48+
just_t<Completion>,
49+
::beman::execution26::detail::product_type<T...>
50+
>,
51+
Env
52+
>
53+
{
54+
using type = ::beman::execution26::completion_signatures<Completion(T...)>;
55+
};
56+
57+
template <typename Completion>
58+
struct impls_for<just_t<Completion>>
59+
: ::beman::execution26::detail::default_impls
60+
{
61+
static constexpr auto start
62+
= []<typename State>(State& state, auto& receiver) noexcept -> void
63+
{
64+
[&state, &receiver]<::std::size_t... I>(::std::index_sequence<I...>)
65+
{
66+
Completion()(::std::move(receiver),
67+
::std::move(state.template get<I>())...);
68+
}(::std::make_index_sequence<State::size()>{});
69+
};
70+
};
71+
}
72+
73+
namespace beman::execution26
74+
{
75+
using just_t = ::beman::execution26::detail::just_t<::beman::execution26::set_value_t>;
76+
using just_error_t = ::beman::execution26::detail::just_t<::beman::execution26::set_error_t>;
77+
using just_stopped_t = ::beman::execution26::detail::just_t<::beman::execution26::set_stopped_t>;
78+
79+
inline constexpr ::beman::execution26::just_t just{};
80+
inline constexpr ::beman::execution26::just_error_t just_error{};
81+
inline constexpr ::beman::execution26::just_stopped_t just_stopped{};
82+
}
83+
84+
// ----------------------------------------------------------------------------
85+
86+
#endif

include/beman/execution26/detail/sender_decompose.hpp

-7
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,6 @@ namespace beman::execution26::detail
109109
typename type::children_type
110110
>{};
111111
}
112-
113-
}
114-
115-
namespace beman::execution26
116-
{
117-
template <typename Sender>
118-
using tag_of_t = typename decltype(::beman::execution26::detail::get_sender_meta(::std::declval<Sender&&>()))::tag_type;
119112
}
120113

121114
// ----------------------------------------------------------------------------

include/beman/execution26/detail/sender_for.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <beman/execution26/detail/sender.hpp>
88
#include <beman/execution26/detail/sender_decompose.hpp>
9+
#include <beman/execution26/detail/tag_of_t.hpp>
910
#include <concepts>
1011

1112
// ----------------------------------------------------------------------------

include/beman/execution26/detail/state_type.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <beman/execution26/detail/impls_for.hpp>
88
#include <beman/execution26/detail/call_result_t.hpp>
99
#include <beman/execution26/detail/sender_decompose.hpp>
10+
#include <beman/execution26/detail/tag_of_t.hpp>
1011
#include <type_traits>
1112

1213
// ----------------------------------------------------------------------------
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// include/beman/execution26/detail/tag_of_t.hpp -*-C++-*-
2+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3+
4+
#ifndef INCLUDED_BEMAN_EXECUTION26_DETAIL_TAG_OF
5+
#define INCLUDED_BEMAN_EXECUTION26_DETAIL_TAG_OF
6+
7+
#include <beman/execution26/detail/sender_decompose.hpp>
8+
#include <type_traits>
9+
10+
// ----------------------------------------------------------------------------
11+
12+
namespace beman::execution26
13+
{
14+
template <typename Sender>
15+
using tag_of_t = typename decltype(
16+
::beman::execution26::detail::get_sender_meta(::std::declval<Sender&&>())
17+
)::tag_type;
18+
}
19+
20+
// ----------------------------------------------------------------------------
21+
22+
#endif

src/beman/execution26/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ target_sources(${TARGET_LIBRARY}
7171
${PROJECT_SOURCE_DIR}/include/beman/execution26/detail/indirect_meta_apply.hpp
7272
${PROJECT_SOURCE_DIR}/include/beman/execution26/detail/inplace_stop_source.hpp
7373
${PROJECT_SOURCE_DIR}/include/beman/execution26/detail/join_env.hpp
74+
${PROJECT_SOURCE_DIR}/include/beman/execution26/detail/just.hpp
7475
${PROJECT_SOURCE_DIR}/include/beman/execution26/detail/make_env.hpp
7576
${PROJECT_SOURCE_DIR}/include/beman/execution26/detail/make_sender.hpp
7677
${PROJECT_SOURCE_DIR}/include/beman/execution26/detail/matching_sig.hpp
@@ -111,6 +112,7 @@ target_sources(${TARGET_LIBRARY}
111112
${PROJECT_SOURCE_DIR}/include/beman/execution26/detail/stop_source.hpp
112113
${PROJECT_SOURCE_DIR}/include/beman/execution26/detail/stoppable_source.hpp
113114
${PROJECT_SOURCE_DIR}/include/beman/execution26/detail/stoppable_token.hpp
115+
${PROJECT_SOURCE_DIR}/include/beman/execution26/detail/tag_of_t.hpp
114116
${PROJECT_SOURCE_DIR}/include/beman/execution26/detail/transform_sender.hpp
115117
${PROJECT_SOURCE_DIR}/include/beman/execution26/detail/type_list.hpp
116118
${PROJECT_SOURCE_DIR}/include/beman/execution26/detail/unstoppable_token.hpp

src/beman/execution26/tests/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
33

44
list(APPEND execution_tests
5+
exec-just.pass
56
exec-snd-expos.pass
67
exec-recv-concepts.pass
78
forward-like.pass

src/beman/execution26/tests/exec-domain-default.pass.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <beman/execution26/detail/default_domain.hpp>
55
#include <beman/execution26/detail/sender.hpp>
66
#include <beman/execution26/detail/sender_decompose.hpp>
7+
#include <beman/execution26/detail/tag_of_t.hpp>
78
#include <test/execution.hpp>
89
#include <concepts>
910

0 commit comments

Comments
 (0)