YOrch 1.0.0
Loading...
Searching...
No Matches
specs.hpp
Go to the documentation of this file.
1#pragma once
2#include <type_traits>
3#include <utility>
4
5namespace yorch {
6
15template <typename T>
16struct from_ctx_t {
18 using type = std::remove_cvref_t<T>;
19};
20
29template <typename T>
32 using type = std::remove_cvref_t<T>;
33};
34
42template <typename T>
45 using type = std::remove_cvref_t<T>;
46};
47
55template <typename T>
58 using type = std::remove_cvref_t<T>;
59};
60
68template <typename T>
71 using type = std::remove_cvref_t<T>;
72};
73
82template <typename T>
83struct value_t {
85 using stored_type = T;
86
87 static_assert(!std::is_reference_v<T>,
88 "value_t<T> must store a non-reference type");
89
91 T v;
92};
93
103template <typename T>
104[[nodiscard]] constexpr auto from_ctx() noexcept
105 -> from_ctx_t<std::remove_cvref_t<T>> {
106 return {};
107}
108
120template <typename T>
121[[nodiscard]] constexpr auto borrow_prev() noexcept
122 -> borrow_prev_t<std::remove_cvref_t<T>> {
123 return {};
124}
125
133template <typename T>
134[[nodiscard]] constexpr auto borrow_prev_mut() noexcept
135 -> borrow_prev_mut_t<std::remove_cvref_t<T>> {
136 return {};
137}
138
150template <typename T>
151[[nodiscard]] constexpr auto copy_prev() noexcept
152 -> copy_prev_t<std::remove_cvref_t<T>> {
153 return {};
154}
155
162template <typename T>
163[[nodiscard]] constexpr auto consume_prev() noexcept
164 -> consume_prev_t<std::remove_cvref_t<T>> {
165 return {};
166}
167
178template <typename T>
179[[nodiscard]] constexpr auto value(T&& v) // NOLINT(readability-identifier-length)
181 using stored_t = std::remove_cvref_t<T>;
182 return value_t<stored_t>{std::forward<T>(v)};
183}
184
185} // namespace yorch
constexpr auto borrow_prev() noexcept -> borrow_prev_t< std::remove_cvref_t< T > >
Creates a spec that borrows T from the direct parent output slot as const T&.
Definition specs.hpp:121
constexpr auto from_ctx() noexcept -> from_ctx_t< std::remove_cvref_t< T > >
Creates a spec that asks execution to fetch T from the context.
Definition specs.hpp:104
constexpr auto copy_prev() noexcept -> copy_prev_t< std::remove_cvref_t< T > >
Creates a spec that copies T from the direct parent output slot as a new value.
Definition specs.hpp:151
constexpr auto value(T &&v) -> value_t< std::remove_cvref_t< T > >
Wraps a value as an owning spec.
Definition specs.hpp:179
constexpr auto consume_prev() noexcept -> consume_prev_t< std::remove_cvref_t< T > >
Creates a spec that consumes T from the direct parent output slot.
Definition specs.hpp:163
constexpr auto borrow_prev_mut() noexcept -> borrow_prev_mut_t< std::remove_cvref_t< T > >
Creates a spec that borrows T from the direct parent output slot as T&.
Definition specs.hpp:134
Describes a parameter that borrows the direct parent output as T&.
Definition specs.hpp:43
std::remove_cvref_t< T > type
Canonical parent payload type used for lookup.
Definition specs.hpp:45
Describes a parameter that borrows the direct parent output as const T&.
Definition specs.hpp:30
std::remove_cvref_t< T > type
Canonical parent payload type used for lookup.
Definition specs.hpp:32
Describes a parameter that consumes the direct parent output.
Definition specs.hpp:69
std::remove_cvref_t< T > type
Canonical parent payload type used for lookup.
Definition specs.hpp:71
Describes a parameter that copies the direct parent output as T.
Definition specs.hpp:56
std::remove_cvref_t< T > type
Canonical parent payload type used for lookup.
Definition specs.hpp:58
Describes a parameter sourced from the execution context by type.
Definition specs.hpp:16
std::remove_cvref_t< T > type
Canonical context key type used for lookup.
Definition specs.hpp:18
Stores a concrete value inside a spec.
Definition specs.hpp:83
T stored_type
Materialized type kept by this spec.
Definition specs.hpp:85
T v
Owned payload forwarded from value(...).
Definition specs.hpp:91