di 0.1.0
Loading...
Searching...
No Matches
try_infallible.h
Go to the documentation of this file.
1#pragma once
2
4#include "di/meta/language.h"
6#include "di/meta/util.h"
7#include "di/meta/vocab.h"
10
11namespace di::vocab {
12namespace detail {
13 struct TryInfallibleFunction : function::pipeline::EnablePipeline {
14 template<concepts::Expected T>
15 requires(concepts::LanguageVoid<meta::ExpectedError<T>> &&
16 concepts::ConstructibleFrom<meta::ExpectedValue<T>, meta::Like<T, meta::ExpectedValue<T>>>)
17 constexpr auto operator()(T&& value) const -> meta::ExpectedValue<T> {
18 return util::forward<T>(value).value();
19 }
20
21 constexpr void operator()(Expected<void, void>) const {}
22
23 template<concepts::Expected T>
24 requires(!concepts::LanguageVoid<meta::ExpectedError<T>> && concepts::ConstructibleFrom<meta::Decay<T>, T>)
25 constexpr auto operator()(T&& value) const -> meta::Decay<T> {
26 return util::forward<T>(value);
27 }
28 };
29}
30
31constexpr inline auto try_infallible = detail::TryInfallibleFunction {};
32}
33
34namespace di {
36}
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
Type< detail::LikeHelper< T, U > > Like
Definition language.h:468
meta::RemoveCVRef< T >::Value ExpectedValue
Definition vocab.h:35
Definition lazy.h:165
constexpr auto try_infallible
Definition try_infallible.h:31
Definition any_storable.h:9