YOrch 1.0.0
Loading...
Searching...
No Matches
factories.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <tuple>
4#include <type_traits>
5#include <utility>
6
7#include "../../detail/bind/tasks.hpp" // IWYU pragma: keep
8#include "types.hpp"
9
10namespace yorch {
11
33template <typename F, typename... Specs>
34constexpr auto bind(F&& f, Specs&&... specs) { // NOLINT(readability-identifier-length)
35 detail::emit_bind_diagnostic<F, Specs...>();
36
37 return bound_task<
38 std::decay_t<F>,
39 std::decay_t<Specs>...
40 >{
41 std::forward<F>(f),
42 std::tuple<std::decay_t<Specs>...>{std::forward<Specs>(specs)...}
43 };
44}
45
59template <typename T, typename F, typename... Specs>
60constexpr auto bind_into(F&& f, Specs&&... specs) {
61 detail::emit_bind_into_diagnostic<T, F, Specs...>();
62
63 return bound_output_task<
64 std::decay_t<F>,
65 T,
66 std::decay_t<Specs>...
67 >{
68 std::forward<F>(f),
69 std::tuple<std::decay_t<Specs>...> {std::forward<Specs>(specs)...}
70 };
71}
72
73template <typename T, typename F, typename... Specs>
74constexpr auto bind_forward_prev(F&& f, Specs&&... specs) {
76
78 std::decay_t<F>,
79 T,
80 std::decay_t<Specs>...
81 >{
82 std::forward<F>(f),
83 std::tuple<std::decay_t<Specs>...> {std::forward<Specs>(specs)...}
84 };
85}
86
87template <typename T, typename F>
88// NOLINTNEXTLINE(cppcoreguidelines-missing-std-forward)
89constexpr void bind_forward_prev_member(F&&) {
90 static_assert(
92 "bind_forward_prev_member(...) requires an explicit receiver binding as its second argument");
93}
94
95template <typename T, typename F, typename ReceiverSpec, typename... Specs>
96constexpr auto bind_forward_prev_member(F&& f, ReceiverSpec&& receiver_spec, Specs&&... specs) {
97 detail::emit_bind_forward_prev_member_diagnostic<T, F, ReceiverSpec, Specs...>();
98
100 std::decay_t<F>,
101 std::decay_t<ReceiverSpec>,
102 T,
103 std::decay_t<Specs>...
104 >{
105 std::forward<F>(f),
106 std::forward<ReceiverSpec>(receiver_spec),
107 std::tuple<std::decay_t<Specs>...> {std::forward<Specs>(specs)...}
108 };
109}
110
111template <typename F>
112// NOLINTNEXTLINE(cppcoreguidelines-missing-std-forward)
113constexpr void bind_member(F&&) {
114 static_assert(
116 "bind_member(...) requires an explicit receiver binding as its second argument");
117}
118
119template <typename F, typename ReceiverSpec, typename... Specs>
120constexpr auto bind_member(F&& f, ReceiverSpec&& receiver_spec, Specs&&... specs) {
121 detail::emit_bind_member_diagnostic<F, ReceiverSpec, Specs...>();
122
123 return bound_member_task<
124 std::decay_t<F>,
125 std::decay_t<ReceiverSpec>,
126 std::decay_t<Specs>...
127 >{
128 std::forward<F>(f),
129 std::forward<ReceiverSpec>(receiver_spec),
130 std::tuple<std::decay_t<Specs>...>{std::forward<Specs>(specs)...}
131 };
132}
133
134template <typename T, typename F>
135// NOLINTNEXTLINE(cppcoreguidelines-missing-std-forward)
136constexpr void bind_into_member(F&&) {
137 static_assert(
139 "bind_into_member(...) requires an explicit receiver binding as its second argument");
140}
141
142template <typename T, typename F, typename ReceiverSpec, typename... Specs>
143constexpr auto bind_into_member(F&& f, ReceiverSpec&& receiver_spec, Specs&&... specs) {
144 detail::emit_bind_into_member_diagnostic<T, F, ReceiverSpec, Specs...>();
145
147 std::decay_t<F>,
148 std::decay_t<ReceiverSpec>,
149 T,
150 std::decay_t<Specs>...
151 >{
152 std::forward<F>(f),
153 std::forward<ReceiverSpec>(receiver_spec),
154 std::tuple<std::decay_t<Specs>...> {std::forward<Specs>(specs)...}
155 };
156}
157
158} // namespace yorch
consteval void emit_bind_forward_prev_member_diagnostic()
consteval void emit_bind_member_diagnostic()
Definition validate.hpp:150
consteval void emit_bind_into_member_diagnostic()
Definition validate.hpp:193
consteval void emit_bind_diagnostic()
Definition validate.hpp:60
consteval void emit_bind_forward_prev_diagnostic()
constexpr bool is_adapter_descriptor_v
Definition adapters.hpp:63
consteval void emit_bind_into_diagnostic()
Definition validate.hpp:104
constexpr auto bind_forward_prev(F &&f, Specs &&... specs)
Definition factories.hpp:74
constexpr void bind_member(F &&)
constexpr auto bind(F &&f, Specs &&... specs)
Creates a bound_task from a callable and matching argument specs.
Definition factories.hpp:34
constexpr void bind_into_member(F &&)
constexpr void bind_forward_prev_member(F &&)
Definition factories.hpp:89
constexpr auto bind_into(F &&f, Specs &&... specs)
Creates a direct-output task from a callable and matching input specs.
Definition factories.hpp:60
Bound direct-output task composed of a member function, receiver spec, and non-output parameter specs...
Definition types.hpp:255
Bound executable task composed of a member function, receiver spec, and per-parameter specs.
Definition types.hpp:213
Bound direct-output task that writes its payload into a provided slot.
Definition types.hpp:76
Bound executable task composed of a callable and per-parameter specs.
Definition types.hpp:28