10template <
typename T,
typename...
Ts>
11inline constexpr std::size_t
type_count_v = (std::size_t{0} + ... + (std::is_same_v<T, Ts> ? 1 : 0));
13template <
typename...
Ts>
29 [[nodiscard]]
static constexpr bool contains() noexcept {
43 constexpr auto get() const -> T& {
45 "no_prev does not carry a direct parent value");
61 using type = std::remove_cv_t<stored_type>;
63 static_assert(!std::is_void_v<type>,
64 "prev_slot_view<T> requires a non-void payload type");
71 [[nodiscard]]
static constexpr bool contains() noexcept {
72 return std::is_same_v<std::remove_cv_t<U>,
type>;
77 static_assert(contains<U>(),
78 "Requested type is not present in the direct parent slot");
104template <
typename... Ts>
107 "yorch::context<Ts...> requires unique types");
119 requires (std::default_initializable<Ts> && ...)
126 template <
typename... Us>
127 requires (
sizeof...(Us) ==
sizeof...(Ts)) &&
128 std::constructible_from<std::tuple<Ts...>, Us&&...>
130 :
storage(std::forward<Us>(xs)...) {}
137 template <
typename T>
138 [[nodiscard]]
static constexpr bool contains() noexcept {
148 template <
typename T>
149 constexpr T&
get() &
noexcept {
150 static_assert(contains<T>(),
151 "T must appear exactly once in yorch::context");
155 template <
typename T>
156 constexpr const T&
get() const& noexcept {
157 static_assert(contains<T>(),
158 "T must appear exactly once in yorch::context");
162 template <
typename T>
163 constexpr T&&
get() &&
noexcept {
164 static_assert(contains<T>(),
165 "T must appear exactly once in yorch::context");
166 return std::get<T>(std::move(
storage));
169 template <
typename T>
170 constexpr const T&&
get() const&& noexcept {
171 static_assert(contains<T>(),
172 "T must appear exactly once in yorch::context");
173 return std::get<T>(std::move(
storage));
186template <
typename Ctx,
typename Prev = no_prev>
198 [[nodiscard]]
constexpr const Prev&
prev_view() const& noexcept {
203template <
typename Ctx>
222template <
typename Prev>
231 [[nodiscard]]
constexpr const Prev&
prev_view() const& noexcept {
constexpr bool unique_types_v
constexpr std::size_t type_count_v
constexpr bool no_prev_always_false_v
constexpr bool is_adapter_descriptor_v
constexpr auto value(T &&v) -> value_t< std::remove_cvref_t< T > >
Wraps a value as an owning spec.
constexpr auto prev_slot(T &value) noexcept -> prev_slot_view< T >
Creates a borrowed view over a direct parent payload object.
Statically typed context container with a compile-time schema.
constexpr const T && get() const &&noexcept
constexpr T && get() &&noexcept
constexpr context(Us &&... xs)
Explicitly constructs the context from the provided objects.
static constexpr bool contains() noexcept
Checks whether a type is present in this context schema.
constexpr const T & get() const &noexcept
std::tuple< Ts... > storage
Underlying storage whose element order matches Ts....
constexpr T & get() &noexcept
Returns the stored object of type T.
constexpr context()=default
Default-constructs the context.
constexpr no_prev prev_view() const noexcept
constexpr Prev & prev_view() &noexcept
Prev prev
Optional direct-parent payload view used by direct-parent access specs.
constexpr const Prev & prev_view() const &noexcept
constexpr no_prev prev_view() const noexcept
Lightweight borrowed view used during execution.
constexpr Prev & prev_view() &noexcept
Prev prev
Optional direct-parent payload view used by direct-parent access specs.
constexpr const Prev & prev_view() const &noexcept
Sentinel view indicating that the current execution has no direct parent output.
static constexpr bool contains() noexcept
constexpr auto get() const -> T &
Always fails because no_prev carries no retrievable value.
Lightweight borrowed view over a direct parent output slot.
std::remove_reference_t< T > stored_type
static constexpr bool contains() noexcept
stored_type & ref
Borrowed reference to the direct parent payload.
constexpr stored_type & get() const noexcept
std::remove_cv_t< stored_type > type