base: pass lambdas by reference in util/attempt.h

genodelabs/genode#4393
This commit is contained in:
Johannes Schlatow 2022-02-01 15:02:42 +01:00 committed by Norman Feske
parent b821776b0d
commit 5aa0fea29b

View File

@ -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);