di 0.1.0
Loading...
Searching...
No Matches
as_fallible.h
Go to the documentation of this file.
1#pragma once
2
5#include "di/meta/util.h"
6#include "di/meta/vocab.h"
8
9namespace di::vocab {
10namespace detail {
11 struct AsFallibleFunction : function::pipeline::EnablePipeline {
12 template<concepts::Expected T>
13 requires(concepts::ConstructibleFrom<meta::Decay<T>, T>)
14 constexpr auto operator()(T&& value) const -> meta::Decay<T> {
15 return util::forward<T>(value);
16 }
17
18 template<typename T, typename R = Expected<meta::UnwrapRefRValue<T>, void>>
19 requires(!concepts::Expected<T> && concepts::ConstructibleFrom<R, T>)
20 constexpr auto operator()(T&& value) const -> R {
21 return util::forward<T>(value);
22 }
23 };
24}
25
26constexpr inline auto as_fallible = detail::AsFallibleFunction {};
27}
28
29namespace di {
31}
constexpr auto value
Definition value.h:34
Conditional< concepts::LanguageArray< RemoveReference< T > >, RemoveExtent< RemoveReference< T > > *, Conditional< concepts::LanguageFunction< RemoveReference< T > >, AddPointer< RemoveReference< T > >, RemoveCVRef< T > > > Decay
Definition language.h:574
Definition lazy.h:165
constexpr auto as_fallible
Definition as_fallible.h:26
Definition any_storable.h:9