Iros
 
Loading...
Searching...
No Matches
into_variant.h
Go to the documentation of this file.
1#pragma once
2
10#include "di/types/prelude.h"
11
12namespace di::execution {
13namespace into_variant_ns {
14 template<typename Send, typename Env>
17
18 template<typename Send, typename Env>
19 struct IntoVariantSetValue : meta::TypeConstant<CompletionSignatures<SetValue(IntoVariantType<Send, Env>)>> {};
20
21 template<typename Value, typename Rec>
22 struct ReceiverT {
23 struct Type : ReceiverAdaptor<Type, Rec> {
25 friend Base;
26
27 public:
28 using Base::Base;
29
30 private:
31 template<typename... Args>
32 requires(concepts::ConstructibleFrom<Value, InPlaceType<meta::DecayedTuple<Args...>>, Args...>)
33 void set_value(Args&&... args) && {
34 execution::set_value(util::move(*this).base(), Value { in_place_type<meta::DecayedTuple<Args...>>,
35 util::forward<Args>(args)... });
36 }
37 };
38 };
39
40 template<concepts::InstanceOf<Variant> Value, concepts::Receiver Rec>
42
43 template<typename Send>
44 struct SenderT {
45 struct Type {
46 using is_sender = void;
47
48 [[no_unique_address]] Send sender;
49
50 private:
51 template<concepts::DecaysTo<Type> Self, typename Env>
58
59 template<concepts::DecaysTo<Type> Self, concepts::Receiver Rec,
60 typename Value = IntoVariantType<meta::Like<Self, Send>, MakeEnv<meta::EnvOf<Rec>>>>
63 friend auto tag_invoke(types::Tag<connect>, Self&& self, Rec receiver) {
64 return execution::connect(util::forward<Self>(self).sender,
65 Receiver<Value, Rec> { util::move(receiver) });
66 }
67
68 constexpr friend auto tag_invoke(types::Tag<get_env>, Type const& self) {
69 return make_env(get_env(self.sender));
70 }
71 };
72 };
73
74 template<concepts::Sender Send>
76
78 template<concepts::Sender Send>
80 auto operator()(Send&& sender) const {
81 return Sender<meta::Decay<Send>> { util::forward<Send>(sender) };
82 }
83 };
84}
85
86constexpr inline auto into_variant = into_variant_ns::Function {};
87}
Definition operations.h:11
Definition sender_in.h:10
Definition sender_to.h:11
Definition into_variant.h:13
meta::Type< SenderT< Send > > Sender
Definition into_variant.h:75
meta::Type< ReceiverT< Value, Rec > > Receiver
Definition into_variant.h:41
meta::ValueTypesOf< Send, Env > IntoVariantType
Definition into_variant.h:16
Definition bulk.h:30
constexpr auto into_variant
Definition into_variant.h:86
constexpr auto make_env
Create an environment with overrides for queries.
Definition make_env.h:147
meta::Type< receiver_interface_ns::ReceiverAdaptor< Self, Base > > ReceiverAdaptor
Definition receiver_adaptor.h:236
decltype(make_env(util::declval< BaseEnv >(), util::declval< Withs >()...)) MakeEnv
Represent an environment with overrides for queries.
Definition make_env.h:189
constexpr auto get_env
Definition get_env.h:27
constexpr auto connect
Definition connect.h:42
constexpr auto set_value
Definition set_value.h:14
T::Type Type
Definition core.h:26
Type< detail::LikeHelper< T, U > > Like
Definition language.h:468
vocab::Tuple< meta::Decay< Types >... > DecayedTuple
Definition decayed_tuple.h:8
GatherSignatures< execution::SetValue, Sender, Env, Tup, Var > ValueTypesOf
Definition value_types_of.h:14
Type< detail::MakeCompletionSignaturesHelper< ExtraSigs, meta::ValueTypesOf< Send, Env, SetValue, meta::List >, meta::Transform< meta::ErrorTypesOf< Send, Env, meta::List >, meta::Quote< SetError > >, meta::Conditional< meta::sends_stopped< Send, Env >, SetStopped, types::CompletionSignatures<> > > > MakeCompletionSignatures
Definition make_completion_signatures.h:36
di::meta::Decay< decltype(T)> Tag
Definition tag_invoke.h:28
Definition into_variant.h:77
ReceiverAdaptor< Type, Rec > Base
Definition into_variant.h:24
Definition into_variant.h:22
constexpr friend auto tag_invoke(types::Tag< get_env >, Type const &self)
Definition into_variant.h:68
Send sender
Definition into_variant.h:48
friend auto tag_invoke(types::Tag< connect >, Self &&self, Rec receiver)
Definition into_variant.h:63
friend auto tag_invoke(types::Tag< get_completion_signatures >, Self &&, Env &&) -> meta::MakeCompletionSignatures< meta::Like< Self, Send >, MakeEnv< Env >, CompletionSignatures<>, IntoVariantSetValue< meta::Like< Self, Send >, MakeEnv< Env > >::template Invoke >
Definition into_variant.h:52
void is_sender
Definition into_variant.h:46
Definition into_variant.h:44
Definition core.h:18
Definition completion_signuatures.h:7
Definition in_place_type.h:5