-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathdefault_impls.hpp
More file actions
64 lines (56 loc) · 2.93 KB
/
default_impls.hpp
File metadata and controls
64 lines (56 loc) · 2.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// include/beman/execution26/detail/default_impls.hpp -*-C++-*-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#ifndef INCLUDED_BEMAN_EXECUTION26_DETAIL_DEFAULT_IMPLS
#define INCLUDED_BEMAN_EXECUTION26_DETAIL_DEFAULT_IMPLS
#include <beman/execution26/detail/allocator_aware_move.hpp>
#include <beman/execution26/detail/callable.hpp>
#include <beman/execution26/detail/empty_env.hpp>
#include <beman/execution26/detail/forward_like.hpp>
#include <beman/execution26/detail/fwd_env.hpp>
#include <beman/execution26/detail/get_allocator.hpp>
#include <beman/execution26/detail/get_env.hpp>
#include <beman/execution26/detail/product_type.hpp>
#include <beman/execution26/detail/sender_decompose.hpp>
#include <beman/execution26/detail/start.hpp>
#include <utility>
// ----------------------------------------------------------------------------
namespace beman::execution26::detail {
/*!
* \brief Helper type providing default implementations for basic_sender
* \headerfile beman/execution26/execution.hpp <beman/execution26/execution.hpp>
* \internal
*/
struct default_impls {
static constexpr auto get_attrs = [](const auto&, const auto&... child) noexcept -> decltype(auto) {
if constexpr (1 == sizeof...(child))
return (::beman::execution26::detail::fwd_env(::beman::execution26::get_env(child)), ...);
else
return ::beman::execution26::empty_env{};
};
static constexpr auto get_env = [](auto, auto&, const auto& receiver) noexcept -> decltype(auto) {
return ::beman::execution26::detail::fwd_env(::beman::execution26::get_env(receiver));
};
static constexpr auto get_state =
[]<typename Sender, typename Receiver>(Sender&& sender, Receiver& receiver) noexcept -> decltype(auto) {
auto&& decompose = ::beman::execution26::detail::get_sender_data(::std::forward<Sender>(sender));
return ::beman::execution26::detail::allocator_aware_move(
::beman::execution26::detail::forward_like<Sender>(decompose.data), receiver);
};
static constexpr auto start = [](auto&, auto&, auto&... ops) noexcept -> void {
(::beman::execution26::start(ops), ...);
};
static constexpr auto complete = []<typename Index, typename Receiver, typename Tag, typename... Args>(
Index, auto&, Receiver& receiver, Tag, Args&&... args) noexcept -> void
requires ::beman::execution26::detail::callable<Tag, Receiver, Args...>
{
static_assert(Index::value == 0);
Tag()(::std::move(receiver), ::std::forward<Args>(args)...);
};
static constexpr auto get_completion_behaviour =
[](const auto& /* env */, const auto& /* data */, const auto&... /* children */) noexcept {
return ::beman::execution26::completion_behaviour::unknown;
};
};
} // namespace beman::execution26::detail
// ----------------------------------------------------------------------------
#endif