di 0.1.0
Loading...
Searching...
No Matches
if_error.h
Go to the documentation of this file.
1#pragma once
2
5#include "di/meta/util.h"
6#include "di/meta/vocab.h"
7
8namespace di::vocab {
9namespace detail {
10 struct IfErrorFunction {
11 template<concepts::Expected T, concepts::InvocableTo<void, meta::Like<T, meta::ExpectedError<T>>&> F>
12 requires(concepts::DecayConstructible<T>)
13 constexpr auto operator()(T&& expected, F&& function) const {
14 if (!expected) {
15 function::invoke(util::forward<F>(function), expected.error());
16 }
17 return util::forward<T>(expected);
18 }
19
20 template<concepts::Expected T, typename F>
21 requires(concepts::DecayConstructible<T> && concepts::LanguageVoid<meta::ExpectedError<T>>)
22 constexpr auto operator()(T&& expected, F&&) const {
23 return util::forward<T>(expected);
24 }
25 };
26}
27
28constexpr inline auto if_error = function::curry_back(detail::IfErrorFunction {}, meta::c_<2ZU>);
29}
30
31namespace di {
32using vocab::if_error;
33}
constexpr auto invoke
Definition invoke.h:100
constexpr auto curry_back
Definition curry_back.h:141
constexpr auto c_
A value of type Constexpr<val>.
Definition constexpr.h:252
Definition lazy.h:165
constexpr auto if_error
Definition if_error.h:28
Definition any_storable.h:9