From b821776b0dd0a3fff169abcc12268f18da6ed6b4 Mon Sep 17 00:00:00 2001 From: Johannes Schlatow Date: Tue, 1 Feb 2022 15:03:47 +0100 Subject: [PATCH] base: add == operator to util/attempt.h This simplifies testing for early return conditions for which the use of lambdas would be quite noisy. genodelabs/genode#4393 --- repos/base/include/util/attempt.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/repos/base/include/util/attempt.h b/repos/base/include/util/attempt.h index 5aa3eb6e3a..d1252efd3d 100644 --- a/repos/base/include/util/attempt.h +++ b/repos/base/include/util/attempt.h @@ -72,6 +72,12 @@ class Genode::Attempt fail_fn(_error); } + bool operator == (ERROR const &rhs) const { + return failed() && (_error == rhs); } + + bool operator == (RESULT const &rhs) const { + return ok() && (_result == rhs); } + bool ok() const { return _ok; } bool failed() const { return !_ok; } };