Loading [MathJax]/extensions/tex2jax.js
Iros
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages Concepts
Loading...
Searching...
No Matches
just.h
Go to the documentation of this file.
1#pragma once
2
6#include "di/meta/util.h"
8
9namespace di::execution {
10namespace just_ns {
11 template<typename CPO, typename Rec, typename... Types>
13 struct Type {
14 public:
15 [[no_unique_address]] Tuple<Types...> values;
16 [[no_unique_address]] Rec receiver;
17
18 private:
19 constexpr friend void tag_invoke(types::Tag<execution::start>, Type& self) {
20 apply(
21 [&](Types&... values) {
22 CPO {}(util::move(self.receiver), util::move(values)...);
23 },
24 self.values);
25 }
26 };
27 };
28
29 template<concepts::OneOf<SetValue, SetStopped, SetError> CPO, concepts::Receiver Rec, typename... Types>
30 using OperationState = meta::Type<OperationStateT<CPO, Rec, Types...>>;
31
32 struct ConstructTag {};
33
34 constexpr inline auto construct_tag = ConstructTag {};
35
36 template<typename CPO, typename... Types>
37 struct SenderT {
38 struct Type {
39 public:
40 using is_sender = void;
41
43
44 template<typename... Us>
45 constexpr explicit Type(ConstructTag, Us&&... values_) : values(util::forward<Us>(values_)...) {}
46
47 [[no_unique_address]] Tuple<Types...> values;
48
49 private:
50 template<concepts::ReceiverOf<CompletionSignatures> Rec>
52 constexpr friend auto tag_invoke(types::Tag<execution::connect>, Type const& sender, Rec receiver) {
53 return OperationState<CPO, Rec, Types...> { sender.values, util::move(receiver) };
54 }
55
56 template<concepts::ReceiverOf<CompletionSignatures> Rec>
58 constexpr friend auto tag_invoke(types::Tag<execution::connect>, Type&& sender, Rec receiver) {
59 return OperationState<CPO, Rec, Types...> { util::move(sender.values), util::move(receiver) };
60 }
61 };
62 };
63
64 template<concepts::OneOf<SetValue, SetStopped, SetError> CPO, typename... Types>
66
67 struct Function {
68 template<concepts::MovableValue... Values>
69 constexpr auto operator()(Values&&... values) const -> concepts::Sender auto {
70 return Sender<SetValue, Values...> { construct_tag, util::forward<Values>(values)... };
71 }
72 };
73
75 template<concepts::MovableValue Error>
76 constexpr auto operator()(Error&& error) const -> concepts::Sender auto {
77 return Sender<SetError, Error> { construct_tag, util::forward<Error>(error) };
78 }
79 };
80
82 constexpr auto operator()() const -> concepts::Sender auto { return Sender<SetStopped> { construct_tag }; }
83 };
84}
85
86constexpr inline auto just = just_ns::Function {};
87constexpr inline auto just_error = just_ns::ErrorFunction {};
88constexpr inline auto just_stopped = just_ns::StoppedFunction {};
89
90using Stopped = decltype(just_stopped());
91constexpr inline auto stopped = just_stopped();
92}
93
94namespace di {
97}
Definition tuple_forward_declaration.h:5
Definition operations.h:34
Definition util.h:71
Definition operations.h:43
Definition sender.h:11
Definition any_storable.h:9
Definition just.h:10
meta::Type< SenderT< CPO, meta::Decay< Types >... > > Sender
Definition just.h:65
meta::Type< OperationStateT< CPO, Rec, Types... > > OperationState
Definition just.h:30
constexpr auto construct_tag
Definition just.h:34
Definition bulk.h:30
decltype(just_stopped()) Stopped
Definition just.h:90
constexpr auto stopped
Definition just.h:91
constexpr auto just_error
Definition just.h:87
constexpr auto just_stopped
Definition just.h:88
constexpr auto just
Definition just.h:86
T::Type Type
Definition core.h:26
di::meta::Decay< decltype(T)> Tag
Definition tag_invoke.h:28
Definition vocab.h:96
StatusCode< Erased< long > > Error
Definition error.h:8
Definition zstring_parser.h:9
constexpr auto apply(F &&f, Tup &&tuple) -> decltype(detail::apply_impl(meta::MakeIndexSequence< meta::TupleSize< Tup > > {}, util::forward< F >(f), util::forward< Tup >(tuple)))
Definition apply.h:22
Definition set_value.h:6
constexpr auto operator()(Error &&error) const -> concepts::Sender auto
Definition just.h:76
constexpr auto operator()(Values &&... values) const -> concepts::Sender auto
Definition just.h:69
Tuple< Types... > values
Definition just.h:15
constexpr friend void tag_invoke(types::Tag< execution::start >, Type &self)
Definition just.h:19
types::CompletionSignatures< CPO(Types...)> CompletionSignatures
Definition just.h:42
Tuple< Types... > values
Definition just.h:47
void is_sender
Definition just.h:40
constexpr friend auto tag_invoke(types::Tag< execution::connect >, Type &&sender, Rec receiver)
Definition just.h:58
constexpr Type(ConstructTag, Us &&... values_)
Definition just.h:45
constexpr friend auto tag_invoke(types::Tag< execution::connect >, Type const &sender, Rec receiver)
Definition just.h:52
constexpr auto operator()() const -> concepts::Sender auto
Definition just.h:82
Definition completion_signuatures.h:7