Iros
 
Loading...
Searching...
No Matches
into_result.h
Go to the documentation of this file.
1#pragma once
2
17#include "di/meta/language.h"
18#include "di/meta/util.h"
19#include "di/platform/prelude.h"
20#include "di/types/prelude.h"
21#include "di/util/move.h"
25
26namespace di::execution {
27namespace into_result_ns {
28 template<typename... Types>
29 struct ResultTypeImplHelper : meta::TypeConstant<meta::DecayedTuple<Types...>> {};
30
31 template<>
33
34 template<typename T>
35 struct ResultTypeImplHelper<T> : meta::TypeConstant<meta::Decay<T>> {};
36
38 template<typename... Types>
40 };
41
42 template<typename... Types>
44
45 template<>
47
48 template<typename T>
49 struct ResultTypeConcatImplHelper<T> : meta::TypeConstant<meta::Decay<T>> {};
50
52 template<typename... Types>
54 };
55
56 template<typename Env, concepts::SenderIn<Env> Send>
59
60 template<typename Env, concepts::SenderIn<Env> Send>
62
63 template<typename Result, typename Rec>
64 struct ReceiverT {
65 struct Type : ReceiverAdaptor<Type, Rec> {
67 friend Base;
68
69 public:
70 using Base::Base;
71
72 private:
73 template<typename T>
75 void set_value(T&& value) && {
76 execution::set_value(util::move(*this).base(), Result(in_place, util::forward<T>(value)));
77 }
78
79 void set_value() &&
81 execution::set_value(util::move(*this).base(), vocab::Result<Result>());
82 }
83
84 void set_error(vocab::Error error) && {
85 execution::set_value(util::move(*this).base(), Result(types::unexpect, util::move(error)));
86 }
87
88 void set_stopped() && {
89 execution::set_value(util::move(*this).base(), Result(types::unexpect, BasicError::OperationCanceled));
90 }
91 };
92 };
93
94 template<typename Value, concepts::Receiver Rec>
96
97 template<typename Send>
98 struct SenderT {
99 struct Type {
100 using is_sender = void;
101
102 [[no_unique_address]] Send sender;
103
104 private:
105 template<concepts::DecaysTo<Type> Self, typename Env>
110
111 template<concepts::DecaysTo<Type> Self, concepts::Receiver Rec,
112 typename Value = ResultType<MakeEnv<meta::EnvOf<Rec>>, meta::Like<Self, Send>>>
115 friend auto tag_invoke(types::Tag<connect>, Self&& self, Rec receiver) {
116 return execution::connect(util::forward<Self>(self).sender,
117 Receiver<Value, Rec> { util::move(receiver) });
118 }
119
120 constexpr friend auto tag_invoke(types::Tag<get_env>, Type const& self) {
121 return make_env(get_env(self.sender));
122 }
123 };
124 };
125
126 template<concepts::Sender Send>
128
130 template<concepts::Sender Send>
132 auto operator()(Send&& sender) const {
133 return Sender<meta::Decay<Send>> { util::forward<Send>(sender) };
134 }
135 };
136
138 template<concepts::Sender Send>
140 auto operator()(Send&& sender) const {
141 return Function {}(execution::into_variant(util::forward<Send>(sender)));
142 }
143 };
144}
145
146constexpr inline auto into_result = into_result_ns::Function {};
148}
Definition operations.h:11
Definition core.h:128
Definition sender_to.h:11
Definition into_result.h:27
meta::Type< ReceiverT< Value, Rec > > Receiver
Definition into_result.h:95
vocab::Result< meta::ValueTypesOf< Send, Env, ResultTypeImpl::template Invoke, ResultTypeConcatImpl::template Invoke > > ResultType
Definition into_result.h:57
vocab::Result< into_variant_ns::IntoVariantType< Send, Env > > WithVariantResultType
Definition into_result.h:61
meta::Type< SenderT< Send > > Sender
Definition into_result.h:127
Definition bulk.h:30
constexpr auto set_error
Definition set_error.h:14
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
constexpr auto into_result
Definition into_result.h:146
meta::Type< receiver_interface_ns::ReceiverAdaptor< Self, Base > > ReceiverAdaptor
Definition receiver_adaptor.h:236
constexpr auto set_stopped
Definition set_stopped.h:14
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 into_variant_result
Definition into_result.h:147
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
GatherSignatures< execution::SetValue, Sender, Env, Tup, Var > ValueTypesOf
Definition value_types_of.h:14
di::meta::Decay< decltype(T)> Tag
Definition tag_invoke.h:28
constexpr auto unexpect
Definition unexpect.h:8
Expected< T, Error > Result
Definition result.h:8
StatusCode< Erased< long > > Error
Definition error.h:8
constexpr auto in_place
Definition in_place.h:8
Definition set_value.h:6
Definition into_result.h:129
ReceiverAdaptor< Type, Rec > Base
Definition into_result.h:66
Definition into_result.h:64
meta::Type< ResultTypeConcatImplHelper< Types... > > Invoke
Definition into_result.h:53
meta::Type< ResultTypeImplHelper< Types... > > Invoke
Definition into_result.h:39
void is_sender
Definition into_result.h:100
friend auto tag_invoke(types::Tag< get_completion_signatures >, Self &&, Env &&) -> types::CompletionSignatures< SetValue(ResultType< MakeEnv< Env >, meta::Like< Self, Send > >)>
Definition into_result.h:106
constexpr friend auto tag_invoke(types::Tag< get_env >, Type const &self)
Definition into_result.h:120
Send sender
Definition into_result.h:102
friend auto tag_invoke(types::Tag< connect >, Self &&self, Rec receiver)
Definition into_result.h:115
Definition into_result.h:98
Definition core.h:18
Definition completion_signuatures.h:7