mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-31 00:24:51 +00:00
base: pass lambdas by reference in util/attempt.h
genodelabs/genode#4393
This commit is contained in:
parent
b821776b0d
commit
5aa0fea29b
@ -53,20 +53,20 @@ class Genode::Attempt
|
||||
Attempt &operator = (Attempt const &) = default;
|
||||
|
||||
template <typename RET, typename ACCESS_FN, typename FAIL_FN>
|
||||
RET convert(ACCESS_FN const &access_fn, FAIL_FN const fail_fn) const
|
||||
RET convert(ACCESS_FN const &access_fn, FAIL_FN const &fail_fn) const
|
||||
{
|
||||
return _ok ? RET { access_fn(_result) }
|
||||
: RET { fail_fn(_error) };
|
||||
}
|
||||
|
||||
template <typename ACCESS_FN, typename FAIL_FN>
|
||||
void with_result(ACCESS_FN const &access_fn, FAIL_FN const fail_fn) const
|
||||
void with_result(ACCESS_FN const &access_fn, FAIL_FN const &fail_fn) const
|
||||
{
|
||||
_ok ? access_fn(_result) : fail_fn(_error);
|
||||
}
|
||||
|
||||
template <typename FAIL_FN>
|
||||
void with_error(FAIL_FN const fail_fn) const
|
||||
void with_error(FAIL_FN const &fail_fn) const
|
||||
{
|
||||
if (!_ok)
|
||||
fail_fn(_error);
|
||||
|
Loading…
x
Reference in New Issue
Block a user